docker / compose

Define and run multi-container applications with Docker
https://docs.docker.com/compose/
Apache License 2.0
33.85k stars 5.21k forks source link

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

Open sc0ttdav3y opened 4 days ago

sc0ttdav3y commented 4 days ago

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 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

ndeloof commented 2 days ago

indeed, docker run should not show this warning, it only makes sense with the up command