Docker Compose warns about orphan containers for the project
Compose displays a warning about orphaned containersShort answer
Compose found containers carrying your project's label whose service is no longer in the Compose file. That follows a removed or renamed service, or a project name shared by two files. Run docker compose up --remove-orphans, or set a distinct project name so unrelated stacks stop mixing.
Fix it fast
1Find out which cause you have
List every container of this project, including stopped ones, and compare it with the services in your Compose file. The ones not in the file are the orphans.
docker compose ps -a docker compose config --services2Match what you see, then jump to its fix
- 1
The warning names a container whose service you deleted or renamed recentlyA service was removed or renamed in the Compose fileFix - 2
The orphans belong to a different application that lives in a folder with the same nameTwo Compose files share one project nameFix - 3
You deliberately run several files for one project, for example with -f, and the orphan warning is just noiseThe warning is wanted off for good, or cleaned up automaticallyFix
- 1
What does the error look like?
Compose displays a warning about orphaned containers
Cause 1 of 3
A service was removed or renamed in the Compose file
1Check
Containers for the old service name still exist, and Compose sees them as part of the project but not defined by the current file. The environment-variable docs define orphans exactly this way.
docker compose ps -a
docker compose config --services2Fix
Remove the leftovers when you bring the stack up. Compose describes this option as removing containers for services not defined in the Compose file.
docker compose up -d --remove-orphans3Verify
The warning is gone and only current services are listed.
docker compose ps -aConfirmed by docs.docker.com
Cause 2 of 3
Two Compose files share one project name
1Check
The project name defaults to the base name of the directory holding the Compose file. Two projects in folders with the same base name, such as app, end up as one project. Compose resolves the name from -p, then COMPOSE_PROJECT_NAME, then the name: attribute, then the folder.
docker compose ls -a2Fix
Give each project its own name with a top-level name: in its Compose file. Then clean up the old group of containers once.
# compose.yaml
name: shop-backend
services:
web:
image: nginx3Verify
The projects are listed separately.
docker compose ls -aConfirmed by docs.docker.com
Cause 3 of 3
The warning is wanted off for good, or cleaned up automatically
1Check
Compose has two switches. COMPOSE_IGNORE_ORPHANS stops it looking for orphans. COMPOSE_REMOVE_ORPHANS removes them when updating a stack, and with it off Compose only shows the warning.
docker compose config --services2Fix
Pick one: ignore the check for this project, or let Compose delete orphans on every update. Delete only when you are sure nothing else uses the project name.
# .env next to compose.yaml
COMPOSE_IGNORE_ORPHANS=true
# or
COMPOSE_REMOVE_ORPHANS=true3Verify
Run up again and confirm the warning no longer shows.
docker compose up -dConfirmed by docs.docker.com
How do I stop it coming back?
- Set name: at the top of every Compose file so the folder name does not decide the project.
- Use docker compose down --remove-orphans before renaming or deleting services.
- Keep one project per Compose setup; use -f overrides only for the same project.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Which stack is behind this page?
Projects of mine built on the same technologies:
Related fixes
Servers
apk cannot find py-pip in an Alpine Docker image
py-pip (no such package):
On current Alpine releases there is no package called py-pip.
2 causes, each with a fixServers
ng serve runs in the container but localhost:4200 does not open
The browser cannot open localhost:4200 although ng serve is running in the container
ng serve listens on localhost by default, which inside a container is the container itself.
3 causes, each with a fixServers
Angular routes return 404 from nginx when you refresh or open a link
The home page loads, but refreshing /some/route shows an nginx 404
Angular routes like /users/42 are not files, so nginx looks for them on disk and returns 404.
3 causes, each with a fixServers
AH00558: Apache in Docker cannot reliably determine its fully qualified domain name
Set the 'ServerName' directive globally to suppress this message
AH00558 is a warning, not a crash.
2 causes, each with a fixServers
Apache in a Docker container logs AH01114 when it proxies to a backend
AH01114: HTTP: failed to make connection to backend: api
Apache's proxy worker could not open a connection to the address in ProxyPass.
5 causes, each with a fixServers
Apache logs SIGWINCH and exits on its own
the httpd container stops although nothing crashed
SIGWINCH is Apache's graceful-stop signal.
2 causes, each with a fix