This repository was archived by the owner on Oct 6, 2025. It is now read-only.
Clean up standalone container startup using Moby idioms#107
Merged
xenoscopic merged 5 commits intomainfrom Jun 27, 2025
Merged
Conversation
Signed-off-by: Jacob Howard <jacob.howard@docker.com>
The start endpoint should be idempotent when trying to start a container that is already started (see [Daemon.containerStart][1], so we can take advantage of that. Once we either created the container, or received a "conflict" (name already in use), we can try starting the container. As there's a time window between a name being reserved and the container to exist (which may produce a 404 during that time window), we ignore "not found" errors, and retry the start. [1]: https://github.com/moby/moby/blob/5318877858c9fc94b5cccc3cf1a75d4ec46951b8/daemon/start.go#L76-L93 Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Signed-off-by: Jacob Howard <jacob.howard@docker.com>
Signed-off-by: Jacob Howard <jacob.howard@docker.com>
This better reflects the function's behavior. Signed-off-by: Jacob Howard <jacob.howard@docker.com>
This was referenced Jun 26, 2025
ilopezluna
approved these changes
Jun 27, 2025
thaJeztah
approved these changes
Jun 27, 2025
Member
thaJeztah
left a comment
There was a problem hiding this comment.
LGTM (but haven't tested 😅), thanks!
| if err := waitForContainerToStart(ctx, dockerClient, controllerContainerName); err != nil { | ||
| _ = dockerClient.ContainerRemove(ctx, resp.ID, container.RemoveOptions{Force: true}) | ||
| if created { | ||
| _ = dockerClient.ContainerRemove(ctx, resp.ID, container.RemoveOptions{Force: true}) |
Member
There was a problem hiding this comment.
Not a blocker; mostly thinking out loud if there would be cases where the remove would fail, and cause issues later (so if it would make sense to print a warning and continue).
Comment on lines
+197
to
+200
| // For some reason, this error case can also manifest as an EOF on the | ||
| // request (I'm not sure where this arises in the Moby server), so we'll | ||
| // let that pass silently too. | ||
| if !(errdefs.IsNotFound(err) || errors.Is(err, io.EOF)) { |
Member
There was a problem hiding this comment.
Still interested in this situation; something we should look into to see what's causing this (as it seems unexpected).
doringeman
approved these changes
Jun 27, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR supersedes #98 and #99. It folds in a few extra changes and rebases on
main.