I am running a CI/CD pipeline that builds my service and ends with docker-compose up -d which brings up the service with a new docker image tag (my-service:tag1).

But when I look at docker ps -a the previous container (that was running image service:tag0) does not appear anymore, and I cannot access its logs.

Why does docker-compose remove the previous container?

Is there a way to see the logs of the previous containers?

1 Answer 1


docker-compose up will remove containers when:

  • The service name is the same, but has a change, in which case the old container is replaced with the new state of the service
  • You include the --remove-orphans option when running docker-compose

Otherwise, if you change the name of the service, and do not specify --remove-orphans, you will see "orphaned" containers still running.

  • The service name is the same for me, because it's the same service, just newer version. So there's no way to prevent this behavior? Maybe remove the name from the container somehow? Commented May 13, 2019 at 8:09
  • 1
    You can change the project name to spin up a second project. That's docker-compose -p new_project up -d
    – BMitch
    Commented May 13, 2019 at 9:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.