Day 20: Docker Quick Reference Guide

Day 20: Docker Quick Reference Guide

Sep 20, 2023ยท

3 min read

Play this article

Finally ๐ŸŽ‰

We have completedโœ… the Docker hands-on and I hope you have learned something interesting from it.๐Ÿ™Œ It's time to take docker to the next level. This cheat sheet will help you to remember everything you learned. This cheat sheet includes commands for both Docker and Docker-Compose, as well as describes the usage of each command.

Here's the Cheat Sheet for docker and docker-compose:

Run a new Container

docker run IMAGE

run a container from the image

docker run --name CONTAINER IMAGE

assign it a name

docker run -p 80:80

assign it a port

docker run -p IMAGE

to map all ports

docker run -d IMAGE

run a container in the background

docker run --hostname

to assign hostname

Manage Containers

docker ps

show a list of running containers

docker ps -a

show a list of all containers

docker rm

to delete a container

docker rm -f

delete a running container

docker container prune

delete the stopped containers

docker stop

stop a running container

docker start

start a stopped container


copy a file from the container to the host


copy a file from the host to a container

docker exec -it

starts a shell inside a container

docker rename

rename the container

docker commit CONTAINER

create an image out of the container

Manage Images

docker pull IMAGE:TAG

download an image

docker push IMAGE

upload an image to the repository

docker rmi

to delete an image

docker images

show a list of images

docker image prune

to delete dangling images

docker image prune -a

delete all the unused images

docker build

build an image from the Dockerfile


tag an image

docker build -t IMAGE DIR

build and tag an image from the docker file

docker save IMAGE > FILE

save an image to a .tar file

docker load -i TARFILE

to load the image from a .tar file

Info & Stats

docker logs CONTAINER

show the logs of a container

docker stats

show stats of running container

docker top CONTAINER

show processes of a container

docker --version

show the version of the docker

docker inspect NAME

show the detailed info about an object

docker diff CONTAINER

show all modified files in the container

docker port CONTAINER

show the mapped port of a container

Docker-Compose Commands

docker-compose build

to build a docker-compose file

docker-compose up

to run a docker-compose file

docker-compose up -d

run a docker-compose file in the background

docker-compose ls

to list the images inside the docker-compose

docker-compose start

start a docker-compose container

docker-compose run

run application of docker-compose file

docker-compose rm

remove the docker container from the docker-compose

docker-compose ps

check container status from docker-compose