ScanSkill

docker compose ps

The command docker compose ps list the containers with current status and exposed ports. By default, all running and stopped containers are shown.

Syntax

$ docker compose ps [OPTIONS] [SERVICE...]

Here,

Options:

  • -s, --quiet→ Only display IDs
  • --all, -a → Show all stopped containers
  • --servuces → Display services
  • --format → Format the output [pretty], [json]

Examples

  • Default shows all the containers either stopped or running
$ docker compose ps

Name                        Command                 State             Ports         
--------------------------------------------------------------------------------------------
cloudyfoxweb_db_1          docker-entrypoint.sh mysqld      Up           3306/tcp             
cloudyfoxweb_web_1         /entrypoint.sh apache2-for ...   Restarting   0.0.0.0:8000->80/tcp
  • Formatted output (--format)
$ docker compose ps --format json

[{"ID":"16ba007b938a15d30b76e1cac670cd6eee68c7290032db481e1aaeb84e7dda34","Name":"docker-web-1","Command":"/docker-entrypoint.sh nginx -g 'daemon off;'","Project":"docker","Service":"web","State":"running","Health":"","ExitCode":0,"Publishers":[{"URL":"","TargetPort":80,"PublishedPort":0,"Protocol":"tcp"},{"URL":"","TargetPort":443,"PublishedPort":0,"Protocol":"tcp"},{"URL":"","TargetPort":8080,"PublishedPort":0,"Protocol":"tcp"}]}]