Skip to content

now we use directly the Docker CLI to run autoremove flag should be p…#9342

Merged
ndeloof merged 1 commit into
docker:v2from
glours:run-rm-issue
Apr 2, 2022
Merged

now we use directly the Docker CLI to run autoremove flag should be p…#9342
ndeloof merged 1 commit into
docker:v2from
glours:run-rm-issue

Conversation

@glours
Copy link
Copy Markdown
Contributor

@glours glours commented Apr 1, 2022

…ass as is

What I did
Pass the rm flag value as is to the Docker CLI when running a container with this flag

fix #9314

(not mandatory) A picture of a cute animal, if possible in relation with what you did
image

Comment thread pkg/compose/run.go
updateServices(&service, observedState)

created, err := s.createContainer(ctx, project, service, service.ContainerName, 1,
opts.Detach && opts.AutoRemove, opts.UseNetworkAliases, opts.Interactive)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was this because there was some code on the compose side to handle this case? (that has been removed?)

Just double-checking if there's not also code on compose's side, causing a potential race on "who gets to remove it first" 😂

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep it was, previously the remove part was done by Compose, see here

func (s *composeService) terminateRun(ctx context.Context, containerID string, opts api.RunOptions) (exitCode int, err error) {
	exitCh, errCh := s.apiClient().ContainerWait(ctx, containerID, container.WaitConditionNotRunning)
	select {
	case exit := <-exitCh:
		exitCode = int(exit.StatusCode)
	case err = <-errCh:
		return
	}
	if opts.AutoRemove {
		err = s.apiClient().ContainerRemove(ctx, containerID, moby.ContainerRemoveOptions{})
	}
	return
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, great! Thanks for confirming 👍

@glours glours requested review from ndeloof and ulyssessouza April 1, 2022 20:34
Copy link
Copy Markdown
Member

@thaJeztah thaJeztah left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@ndeloof ndeloof merged commit fcff36f into docker:v2 Apr 2, 2022
@glours glours deleted the run-rm-issue branch April 2, 2022 07:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

docker compose run --rm no longer working on 2.3.x

3 participants