Docker Command Cheatsheet

Build

Command Description
docker build -t my_program:v1 . Build an image using the Dockerfile in current directory

Execution

 

Command Description
docker run -d -it redis_celery Run container, detached. CMD/Excute in Dockerfile will execute as PID1l
docker run -d -it redis_celery ping 8.8.8.8 -c1 Run container. Execute ping command

Dockerfile

Command Description
FROM
RUN
ENV
COPY
EXPOSE
CMD
ENTRYPOINT

 

General

Command Description
CTRL+P then CTRL+Q Detach from container
docker ps -a ; docker attach <id> Attach to container
docker pull -a fedora Pull all fedora images from the docker public repo
docker rm $(docker ps -a –since=”sick_mcnulty” -q)
docker stop $(docker ps -a -q) stop all containers
docker rm $(docker ps -a -q) Delete all containers
docker rmi $(docker images -q) Delete all images
docker info Display system-wide information
docker inspect <id> Return low-level information on a container or image
docker images Show list of docker images
docker port <id> Show exposed ports

 

 

Rick Donato

Want to become a Docker and Kubernetes expert?

Here is our hand-picked selection of the best courses you can find online:
Docker Mastery course
Kubernetes Mastery course
and our recommended certification practice exams:
AlphaPrep Practice Tests - Free Trial