Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is docker-compose ps different from docker ps?

Tags:

docker

Why does docker compose create containers that are only accecible from docker-compose ps and that persist after killing running container ?

like image 340
Sofia Namoun Avatar asked Jul 22 '26 09:07

Sofia Namoun


1 Answers

It doesn't.

docker ps only shows running containers, docker-compose ps shows all containers related to the current compose file, running and stopped. docker-compose kill just force stops the container and it can be restarted with docker-compose start, it will therefore be visible when running docker-compose ps but not docker ps.

To list all containers with docker use docker ps -a. To removed stopped containers related to a compose file run docker-compose rm, if you want to stop and remove all containers, have a look at docker-compose down.

like image 68
erikced Avatar answered Jul 24 '26 05:07

erikced