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

compose down --remove-orphans #1344

Closed
dbanty opened this issue Aug 29, 2022 · 5 comments · Fixed by #1366
Closed

compose down --remove-orphans #1344

dbanty opened this issue Aug 29, 2022 · 5 comments · Fixed by #1366

Comments

@dbanty
Copy link

dbanty commented Aug 29, 2022

What is the problem you're trying to solve

Similar to #342, I would like to have the --remove-orphans option for compose down.

Describe the solution you'd like

Add the --remove-orphans flag to compose down.

Additional context

No response

@stillfox-lee
Copy link
Contributor

I'd like to help.

@dbanty dbanty changed the title compose up --remove-orphans compose down --remove-orphans Aug 30, 2022
@fahedouch
Copy link
Member

plz go ahead @stillfox-lee

@stillfox-lee
Copy link
Contributor

Hi @dbanty , I find a compatibility issue with docker and containerd in orphan container use case. When we execute docker compose down it will return failed. Docker found an orphan container still in active, and it won't remove the related network. But containerd just remove network and leave the orphan container alone.

cat full.yaml
version: '3.1'

services:
  service1:
    image: alpine:3.13
    command: "sleep infinity"
  orphan:
    image: alpine:3.13
    command: "sleep infinity"

---

cat orphan.yaml
version: '3.1'

services:
  orphan:
    image: alpine:3.13
    command: "sleep infinity"

docker:

docker compose -f full.yaml up -d
[+] Running 3/3
 ⠿ Network compose-orphans_default       Created                                                                                                                                          0.1s
 ⠿ Container compose-orphans-orphan-1    Started                                                                                                                                          0.6s
 ⠿ Container compose-orphans-service1-1  Started

---
docker compose -f orphan.yaml down -v
[+] Running 1/1
 ⠿ Container compose-orphans-orphan-1  Removed                                                                                                                                           10.3s
 ⠿ Network compose-orphans_default     Error                                                                                                                                              0.0s
failed to remove network compose-orphans_default: Error response from daemon: error while removing network: network compose-orphans_default id 497799fb7117a56780a82e4bbfbfbfe984d5fcf41cf9af32af28d5c3e1cd33b1 has active endpoints

containerd:

nerdctl compose -f full.yaml up -d
INFO[0000] Creating network compose-orphans_default
INFO[0000] Ensuring image alpine:3.13
INFO[0000] Ensuring image alpine:3.13
INFO[0000] Creating container compose-orphans_service1_1
INFO[0000] Creating container compose-orphans_orphan_1

--- 
nerdctl compose -f orphan.yaml down -v
INFO[0000] Removing container compose-orphans_orphan_1
INFO[0000] Removing network compose-orphans_default

And the deviation also cause CI fail.

@AkihiroSuda
Copy link
Member

Docker's behavior is correct, and eventually we have to fix the behavior of nerdctl, but that can be worked out later.

Could you find a test case that works with Docker, and confirm that it works with nerdctl too?
Thanks

@stillfox-lee
Copy link
Contributor

Could you find a test case that works with Docker, and confirm that it works with nerdctl too? Thanks

Sure.

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

Successfully merging a pull request may close this issue.

4 participants