Docker Command Cheatsheet

Build

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

Execution

 

CommandDescription
docker run -d -it redis_celeryRun container, detached. CMD/Excute in Dockerfile will execute as PID1l
docker run -d -it redis_celery ping 8.8.8.8 -c1Run container. Execute ping command

Dockerfile

CommandDescription
FROM
RUN
ENV
COPY
EXPOSE
CMD
ENTRYPOINT

 

General

CommandDescription
CTRL+P then CTRL+QDetach from container
docker ps -a ; docker attach <id>Attach to container
docker pull -a fedoraPull 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 infoDisplay system-wide information
docker inspect <id>Return low-level information on a container or image
docker imagesShow 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