Docker Cheatsheet
Docker Container Commands:
Create a Container:
docker create [OPTIONS] IMAGE [COMMAND] [ARG...]
Start a Container:
docker start [OPTIONS] CONTAINER
Stop a Container:
docker stop [OPTIONS] CONTAINER
Remove a Container:
docker rm [OPTIONS] CONTAINER
List Running Containers:
docker ps
List All Containers(both stopped and running)
docker ps -a
Inspect a Container:
docker inspect CONTAINER_ID
List the port mappings for a container
docker port CONTAINER_ID
To view resource usage statistics for one or more container
docker stats CONTAINER_ID
To display the running processes inside a specified container
docker top CONTAINER_ID
Execute a Command in a Running Container:
docker exec [OPTIONS] CONTAINER COMMAND [ARG...]
To remove all stopped containers
docker container prune
Docker Image Commands:
List Local Images:
docker images
Pull an Image from Docker Hub:
docker pull IMAGE_NAME
Remove an Image:
docker rmi IMAGE_NAME
Build an Image from Dockerfile:
docker build [OPTIONS] PATH_TO_DOCKERFILE
Save one or more Docker images to a tar archive file.
docker save [OPTIONS] IMAGE [IMAGE...]
Load Docker images from an archive file
docker load [OPTIONS]
Log in to Docker Hub:
docker login
Push an Image to Docker Hub:
docker push IMAGE_NAME
To remove unused or dangling images
docker image prune
Docker Volume Commands:
List Volumes:
docker volume ls
Create a Volume:
docker volume create VOLUME_NAME
Remove a Volume:
docker volume rm VOLUME_NAME
Docker Network Commands:
List Networks:
docker network ls
Create a Network:
docker network create NETWORK_NAME
Remove a Network:
docker network rm NETWORK_NAME
Docker Compose Commands:
Start Containers Defined in a Compose file:
docker-compose up [OPTIONS]
Stop Containers Defined in a Compose file:
docker-compose down [OPTIONS]
View Compose logs:
docker-compose logs [SERVICE]
List Containers:
docker-compose ps
Subscribe to my newsletter
Read articles from Ronke Akinyemi directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
Ronke Akinyemi
Ronke Akinyemi
DevOps Engineer