docker-compose create suggests --remove-orphans, which doesn't work
Description
If it finds orphaned containers, docker-compose create will suggest running again with --remove-orphans, which is not a flag that create accepts.
Steps to reproduce the issue:
docker-compose create- change the name of a service
docker-compose createagain, which will complain:WARN[0000] Found orphan containers ([foo, bar]) 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.docker-compose create --remove-orphans
Describe the results you received:
$ docker-compose create --remove-orphans
unknown flag: --remove-orphans
Describe the results you expected: Orphaned containers are removed.
Output of docker compose version:
Docker Compose version 2.9.0
Output of docker info:
Client:
Context: default
Debug Mode: false
Plugins:
buildx: Docker Buildx (Docker Inc., v0.8.2-docker)
compose: Docker Compose (Docker Inc., 2.9.0)
Server:
Containers: 6
Running: 4
Paused: 0
Stopped: 2
Images: 66
Server Version: 20.10.17
Storage Driver: btrfs
Build Version: Btrfs v5.18.1
Library Version: 102
Logging Driver: json-file
Cgroup Driver: systemd
Cgroup Version: 2
Plugins:
Volume: local
Network: bridge host ipvlan macvlan null overlay
Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
Swarm: inactive
Runtimes: io.containerd.runtime.v1.linux runc io.containerd.runc.v2
Default Runtime: runc
Init Binary: docker-init
containerd version: 10c12954828e7c7c9b6e0ea9b0c02b01407d3ae1.m
runc version:
init version: de40ad0
Security Options:
seccomp
Profile: default
cgroupns
Kernel Version: 5.15.55-2-lts
Operating System: Arch Linux
OSType: linux
Architecture: x86_64
CPUs: 8
Total Memory: 7.456GiB
Name: peanut.codl.fr
ID: HTBR:M3DN:3IFA:VREG:7FMW:REU4:X23W:UUSQ:33P4:WQ74:CZTP:IHAT
Docker Root Dir: /var/lib/docker
Debug Mode: false
Registry: https://index.docker.io/v1/
Labels:
Experimental: false
Insecure Registries:
127.0.0.0/8
Live Restore Enabled: false
FYI, the only compose commands I've found in the docs that support --remove-orphans are up and down.
Docs:
https://docs.docker.com/engine/reference/commandline/compose_down/
https://docs.docker.com/engine/reference/commandline/compose_up/
I've run into this with docker compose run..... as well, so I think the message really just needs to change from:
you can run this command with the --remove-orphans flag to clean it up.
to:
you can run 'docker compose up/down --remove-orphans' to clean it up.
Unless maintainers want to add --remove-orphans support to all commands which trigger this message.
Still an issue
message indeed suggests to use --remove-orphans which is a compose up flag.
simplest option is to introduce this flag in compose create as well
@ndeloof, as noted in the comments above, this message also shows on run. Should support for the option be added to that command as well?
@ndeloof I naively followed your example on the run command and opened a PR if that's helpful: https://github.com/docker/compose/pull/10166