How to keep previous containers on docker-compose up? 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?
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.