Skip to content

Docker CLI

List all docker containers, running and stopped:

docker ps --all

Start a container from an image, with a custom name:

docker run --name ubuntu ubuntu:latest

Start an existing container:

docker start ubuntu

Stop an existing container:

docker stop ubuntu

Remove a stopped container:

docker rm ubuntu

Pull an image from dockerhub:

docker pull ubuntu

Display the list of already downloaded images:

docker images

Fetch and follow the logs of a container:

docker logs -f ubuntu

Cleanup dangling images, containers, volumes, and networks

docker system prune

Open a shell inside a running container:

docker exec -it ubuntu /bin/bash
docker exec -it ubuntu uname -a
docker exec -it ubuntu pwd

Stop and Remove ALL containers

docker stop $(docker ps -aq); docker rm $(docker ps -aq)

Stop ALL containers

docker stop $(docker ps -a -q)

Remove ALL containers

docker rm -f $(docker ps -a -q)