Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] v2.23.0 broke docker-compose down -v --remove-orphans NAME ? #11203

Closed
ValiDrv opened this issue Nov 20, 2023 · 4 comments · Fixed by #11204
Closed

[BUG] v2.23.0 broke docker-compose down -v --remove-orphans NAME ? #11203

ValiDrv opened this issue Nov 20, 2023 · 4 comments · Fixed by #11204
Assignees
Labels

Comments

@ValiDrv
Copy link

ValiDrv commented Nov 20, 2023

Description

I have a docker-compose.yml file with multiple common services, db, redis, proxies, etc, referenced to via depends_on, and a few main services, web1, web2, etc.

After starting all services correctly, if I try to bring one service down using:
docker-compose down -v --remove-orphans web1

With version v2.23.0 and up, it will bring down all services listed in the docker-compose file (including web2, the common services, etc)

With version v2.22.0 and bellow, it will bring down only the expected service web1, and any other service which is not being depended on.

Is this an expected behaviour? or a bug which was introduced via v2.23.0 with the profile updates?

Steps To Reproduce

No response

Compose Version

Docker Compose version v2.23.1 - bug
Docker Compose version v2.23.0 - bug
Docker Compose version v2.22.0 - works
Docker Compose version v2.20.0 - works

Docker Environment

Distributor ID:	Ubuntu
Description:	Ubuntu 22.04.3 LTS
Release:	22.04
Codename:	jammy


Client:
 Version:    24.0.5
 Context:    default
 Debug Mode: false
 Plugins:
  compose: Docker Compose (Docker Inc.)
    Version:  v2.2.3
    Path:     /root/.docker/cli-plugins/docker-compose

Anything else?

No response

@ndeloof
Copy link
Contributor

ndeloof commented Nov 20, 2023

I can confirm this is a regression

@rgeorgiev583
Copy link

Unfortunately, the fix for this bug has the side effect that it is now impossible to use down with --remove-orphans for fully deleting a deployment without specifying all of the enabled profiles in it.

For instance, consider the following compose.yaml:

services:
  foo:
    image: busybox
    command: sleep inf

  bar:
    image: busybox
    command: sleep inf
    profiles:
    - bar

If I bring up the bar profile with up -d, both the foo and bar services would be created:

> docker compose --profile bar up -d
[+] Running 3/3
 ✔ Network down-remove-orphans-test_default  Created                                                                                                                                                        0.1s 
 ✔ Container down-remove-orphans-test-bar-1  Started                                                                                                                                                        0.0s 
 ✔ Container down-remove-orphans-test-foo-1  Started

However, if I try to bring down the deployment using --remove-orphans, the following happens:

> docker compose down --remove-orphans
[+] Running 2/1
 ✔ Container down-remove-orphans-test-foo-1  Removed                                                                                                                                                       10.3s 
 ! Network down-remove-orphans-test_default  Resource is still in use

In order to bring down the whole deployment, I now have to do the following:

> docker compose --profile bar down
[+] Running 3/3
 ✔ Container down-remove-orphans-test-foo-1  Removed                                                                                                                                                       10.3s 
 ✔ Container down-remove-orphans-test-bar-1  Removed                                                                                                                                                       10.4s 
 ✔ Network down-remove-orphans-test_default  Removed

This is quite inconvenient to me.

@ndeloof
Copy link
Contributor

ndeloof commented Nov 27, 2023

"orphans" targets containers created by compose run command or declaring a service that does not exist in the know compose model, this is not about disabled services (profiles didn't existed as --remove-orphans was introduced)

To cover your use case, you can either ru compose down with a project name (to get all running services, without consideration for a compose.yaml model) or run compose --profile '*' down to enable all profiles

@rgeorgiev583
Copy link

@ndeloof thanks, this solved my problem!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants