Skip to content

Ignore missing containers when compose down/stop -p#11692

Merged
ndeloof merged 3 commits intodocker:mainfrom
koooge:11686-down-project
Apr 11, 2024
Merged

Ignore missing containers when compose down/stop -p#11692
ndeloof merged 3 commits intodocker:mainfrom
koooge:11686-down-project

Conversation

@koooge
Copy link
Contributor

@koooge koooge commented Apr 6, 2024

What I did
Fix the error of docker compose down/stop with -p could not find <container>: not found when there are services depend_on missing containers. The scenario is particularly likely to happen when using initial containers. docker system prune is one reason to remove init containers, for example.

Related issue

fixes #11686

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

@koooge koooge force-pushed the 11686-down-project branch from e900bd3 to 6392799 Compare April 7, 2024 14:10
@koooge koooge changed the title Ignore missing containers when compose down --remove-orphans Ignore missing containers when compose down/stop -p Apr 7, 2024
// InDependencyOrder applies the function to the services of the project taking in account the dependency order
func InDependencyOrder(ctx context.Context, project *types.Project, fn func(context.Context, string) error, options ...func(*graphTraversal)) error {
graph, err := NewGraph(project, ServiceStopped)
graph, err := NewGraph(project, ServiceStopped, false)
Copy link
Contributor

Choose a reason for hiding this comment

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

an alternative approach is to use project.WithServicesTransform to set DependsOn.Required = false on all services, s you don't need API change

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed 0e58676

koooge added 3 commits April 9, 2024 23:30
Signed-off-by: koooge <koooooge@gmail.com>
Signed-off-by: koooge <koooooge@gmail.com>
@koooge koooge force-pushed the 11686-down-project branch from 6392799 to 0e58676 Compare April 9, 2024 23:45
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.

[BUG] compose down fails when it depends_on missing init containers

2 participants