Docker Commands

Usually if i don’t use for sometimes the Docker commands, i forget them, so here a list, as reminder, of the commands that i usually use:

  • Forces running containers to stop by sending a SIGKILL signal.

    docker-compose kill

  • Builds, (re)creates, starts, and attaches to containers for a service.

    docker-compose up

  • Stops containers and removes containers, networks, volumes, and images created by up.

    docker-compose down

  • To list all the running and stopped containers:


    docker container ls

  • To list all the running containers:

    docker ps -a -f status=running
  • To list all running and stopped containers, showing only their container id

    docker ps -aq
  • To list all the containers created irrespective of its state:


    docker container ls -a

  • To show only running containers use the given command:


    docker ps

  • To show all containers use the given command:

    docker ps -a
  • To show the latest created container (includes all states) use the given command:

    docker ps -l

  • To show n last created containers (includes all states) use the given command:

    docker ps -n=-1
  • To display total file sizes use the given command:

    docker ps -s
  • To delete ALL unused data (i.e., in order: containers stopped, volumes without containers and images with no containers):

    docker system prune
  • To remove all non-running containers:

    docker rm `docker ps -aq -f status=exited`