Skip to content

Commit

Permalink
sorted out --rm/--no-rm options
Browse files Browse the repository at this point in the history
  • Loading branch information
oclaussen committed Apr 8, 2018
1 parent c6f54a6 commit ea2a0ed
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
1 change: 1 addition & 0 deletions pkg/container/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ type Options struct {
Client *client.Client
Image string
Name string
Remove bool
Interactive bool
Interpreter []string
Entrypoint string
Expand Down
2 changes: 1 addition & 1 deletion pkg/container/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func createContainer(ctx context.Context, options Options) (string, error) {
Entrypoint: getEntrypoint(options),
},
&container.HostConfig{
AutoRemove: true,
AutoRemove: options.Remove,
Binds: options.Volumes,
VolumesFrom: options.VolumesFrom,
},
Expand Down
6 changes: 5 additions & 1 deletion pkg/container/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,14 @@ func runContainer(ctx context.Context, containerID string, options Options) erro
}
}()

condition := container.WaitConditionNextExit
if options.Remove {
condition = container.WaitConditionRemoved
}
waitChannel, waitErrorChannel := options.Client.ContainerWait(
ctx,
containerID,
container.WaitConditionRemoved,
condition,
)

err = options.Client.ContainerStart(
Expand Down

0 comments on commit ea2a0ed

Please sign in to comment.