compose icon indicating copy to clipboard operation
compose copied to clipboard

[BUG] docker-compose run suggests --remove-orphans, which doesn't work

Open sc0ttdav3y opened this issue 1 year ago • 1 comments

Description

If it finds orphaned containers, docker compose run will suggest running again with --remove-orphans, which is not a flag that docker compose run accepts.

Steps To Reproduce

  1. docker-compose run $SERVICE
  2. (I'm not entirely sure why containers get orphaned, but just re-running this in my case is building up a big list of them, probably due to their Dockerfile failing)
  3. docker-compose run $SERVICE again — you will see:
WARN[0000] Found orphan containers ([...]) for this project. If you removed or renamed this service in your compose file, you can run this command with the --remove-orphans flag to clean it up.
  1. docker compose run $SERVICE --remove-orphans
node: bad option: --remove-orphans

Compose Version

  • Docker version 27.2.0, build 3ab4256
  • Docker Compose version v2.29.2-desktop.2
  • Docker-Compose version: (command not found)
  • MacOS 15.0.1 on an Apple Silicon mac

Docker Environment

Client: Version: 27.2.0 Context: desktop-linux Debug Mode: false Plugins: buildx: Docker Buildx (Docker Inc.) Version: v0.16.2-desktop.1 Path: /Users/XXXX/.docker/cli-plugins/docker-buildx compose: Docker Compose (Docker Inc.) Version: v2.29.2-desktop.2 Path: /Users/XXXX/.docker/cli-plugins/docker-compose debug: Get a shell into any image or container (Docker Inc.) Version: 0.0.34 Path: /Users/XXXX/.docker/cli-plugins/docker-debug desktop: Docker Desktop commands (Alpha) (Docker Inc.) Version: v0.0.15 Path: /Users/XXXX/.docker/cli-plugins/docker-desktop dev: Docker Dev Environments (Docker Inc.) Version: v0.1.2 Path: /Users/XXXX/.docker/cli-plugins/docker-dev extension: Manages Docker extensions (Docker Inc.) Version: v0.2.25 Path: /Users/XXXX/.docker/cli-plugins/docker-extension feedback: Provide feedback, right in your terminal! (Docker Inc.) Version: v1.0.5 Path: /Users/XXXX/.docker/cli-plugins/docker-feedback init: Creates Docker-related starter files for your project (Docker Inc.) Version: v1.3.0 Path: /Users/XXXX/.docker/cli-plugins/docker-init sbom: View the packaged-based Software Bill Of Materials (SBOM) for an image (Anchore Inc.) Version: 0.6.0 Path: /Users/XXXX/.docker/cli-plugins/docker-sbom scout: Docker Scout (Docker Inc.) Version: v1.13.0 Path: /Users/XXXX/.docker/cli-plugins/docker-scout

Server: Containers: 46 Running: 0 Paused: 0 Stopped: 46 Images: 79 Server Version: 27.2.0 Storage Driver: overlay2 Backing Filesystem: extfs Supports d_type: true Using metacopy: false Native Overlay Diff: true userxattr: false Logging Driver: json-file Cgroup Driver: cgroupfs Cgroup Version: 2 Plugins: Volume: local Network: bridge host ipvlan macvlan null overlay Log: awslogs fluentd gcplogs gelf journald json-file local splunk syslog Swarm: inactive Runtimes: io.containerd.runc.v2 runc Default Runtime: runc Init Binary: docker-init containerd version: 8fc6bcff51318944179630522a095cc9dbf9f353 runc version: v1.1.13-0-g58aa920 init version: de40ad0 Security Options: seccomp Profile: unconfined cgroupns Kernel Version: 6.10.4-linuxkit Operating System: Docker Desktop OSType: linux Architecture: aarch64 CPUs: 12 Total Memory: 3.828GiB Name: docker-desktop ID: b4bc8171-da6b-43e0-8137-349e2702ef62 Docker Root Dir: /var/lib/docker Debug Mode: false HTTP Proxy: http.docker.internal:3128 HTTPS Proxy: http.docker.internal:3128 No Proxy: hubproxy.docker.internal Labels: com.docker.desktop.address=unix:///Users/XXXX/Library/Containers/com.docker.docker/Data/docker-cli.sock Experimental: false Insecure Registries: hubproxy.docker.internal:5555 127.0.0.0/8 Live Restore Enabled: false

Anything else?

This issue is identical to closed issue https://github.com/docker/compose/issues/9718, which addressed the issue for "docker compose create ..." back in 2022.

In that ticket, a follow-up PR https://github.com/docker/compose/pull/10166 was also merged claiming to address this issue for "docker compose run" in 2023 targeting versions v.2.16, although I'm experiencing this on v2.29 in 2024.

Given this history, I wonder whether I'm doing something wrong, or whether there's been a subsequent regression in that PR or an environmental consideration.

Hope I've given enough info here. And big thanks to all the volunteers on this project!

Thanks... Scott

sc0ttdav3y avatar Oct 16 '24 06:10 sc0ttdav3y

My bad, flag is well supported, just need to be set after the run command, not as argument:

$ docker compose run --remove-orphans SERVICE <command to run>

ndeloof avatar Oct 21 '24 06:10 ndeloof

Thanks for your response, @ndeloof. I would never had guessed that one.

sc0ttdav3y avatar Oct 21 '24 07:10 sc0ttdav3y