KEMBAR78
Docker Cheatsheet | PDF | Software Engineering | Computer Science
0% found this document useful (0 votes)
47 views2 pages

Docker Cheatsheet

This document is a comprehensive cheat sheet for Docker commands, covering basic commands, network commands, image and container information, and miscellaneous examples. It includes commands for searching, pulling, pushing images, managing containers, and networking functionalities. Additionally, it provides options keywords for command customization.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
47 views2 pages

Docker Cheatsheet

This document is a comprehensive cheat sheet for Docker commands, covering basic commands, network commands, image and container information, and miscellaneous examples. It includes commands for searching, pulling, pushing images, managing containers, and networking functionalities. Additionally, it provides options keywords for command customization.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Docker commands Cheat Sheet

by angel_ceed via cheatography.com/81998/cs/19584/

Basic Docker Commands Network Commands

docker search Search Docker Hub for images docker network ls List networks
searchterm docker network inspect <Ne​​tw​o​r​k> Inspect a network
docker pull Downloads an image from Docker Hub docker network create <Ne​​tw​o​r​k> Create a network
user/image
docker network rm <Ne​​tw​o​r​k> Removes a network
docker login Authen​ticate to Docker Hub (or other Docker
docker network connect <Ne​​tw​o​r​k> Connect a container to the
registry)
<Co​​nt​a​i​ne​​r> network
docker push Uploads an image to Docker Hub. You must be
docker network connect --ip <IP> Specify the IP address of
user/image⠀⠀⠀ authen​ticated to run this command
<Ne​​tw​o​r​k> <Co​​nt​a​i​ne​​r> container interface
docker info Retrieves docker config​​ur​ation
docker network disconnect <Ne​​tw​o​r​‐ Disconnect container from
docker version Retrieves docker versioning k_​​Nam​​e> <Co​​nt​a​i​ne​​r> network

<Ne​​tw​o​r​k> can be replaced with the network ID or NAME


Image and Container Inform​ation

docker ps List all running containers Work With Images and Containers
docker ps -a List all container instances, with their ID
docker run -it user/image Runs an image, creating a container and
and status
changing the terminal to the terminal
docker images Lists all images on the local machine within the container
docker history <us​er>​/<i​‐ Lists the history of an image docker run -p <ho​stp​ort​‐ Run an image in detached mode with
mag​e> >:<​con​tai​ner​por​t> -d port forwarding
docker logs <co​nta​ine​r> Displays the logs from a running user/image
container docker start <co​nta​ine​r> Start a container
docker port <co​nta​ine​r> Displays the exposed port of a running docker exec <co​nta​ine​r> Executes a command within a running
container [shell command] container, e.g. /bin/bash
docker diff <co​nta​ine​r> Lists the changes made to a container docker attach <co​nta​ine​‐ Changes the command prompt from the
docker logs [-f] <co​nta​‐ Read container stdout r> host to a running container
ine​r> docker stop <co​nta​ine​r> Stop a container
docker top <co​nta​ine​r> Show running processes docker rm -f <co​nta​ine​r> Delete a container
docker inspect <co​nta​‐ Show container config​​ur​ation docker create <im​age​>: Create image
ine​r> <​tag>
docker events Show container events docker rmi <im​age> Delete an image
<co​nta​ine​r> can be replaced with container name or ID docker tag <us​er>​/<i​‐ Add a new tag to an image
mag​e>:​<ta​g> <us​er>​/<i​‐
mag​e>:​<new tag>
ctrl+p then ctrl+q Changes the command prompt from the
host to a running container

<co​nta​ine​r> can be replaced with container name or ID

By angel_ceed Published 8th May, 2019. Sponsored by ApolloPad.com


cheatography.com/angel- Last updated 10th May, 2019. Everyone has a novel in them. Finish
ceed/ Page 1 of 2. Yours!
https://apollopad.com
Docker commands Cheat Sheet
by angel_ceed via cheatography.com/81998/cs/19584/

Misc. Examples

sudo docker commit contai​nterID userna​‐ Commit from container


me/​ima​gename to an image
docker push userna​me/​ima​gename Docker push example
(after logging)
docker run -it -v /host/​dir​ect​ory​:/c​ont​ain​‐ Mount a host directory in
er/​dir​ectory [options] image [command] a Docker container
docker cp /host/​dir​ect​ory​/fi​le.ext Copy file from host
container:/cont​ain​er/​dir​ectory machine to docker
container
docker rmi $(docker images -a -q) Delete all Docker
images

docker rm $(sudo docker ps -a -q) Delete all stopped


containers
docker rm $(sudo docker ps -a | grep Delete all containers in
Exit | cut -d ' ' -f 1) Exit state
docker save imagename > filename .tar Export image to a file
docker load < filename .tar Load image from file
docker [command] --help Command help

Options Keywords

-p, –-publish Host to container port mapping


--publ​​is​h-all Publish all ports
-d, –-detach Run in background
-e, –-env Set env vars
-v, --volume Mount files or direct​​ories

By angel_ceed Published 8th May, 2019. Sponsored by ApolloPad.com


cheatography.com/angel- Last updated 10th May, 2019. Everyone has a novel in them. Finish
ceed/ Page 2 of 2. Yours!
https://apollopad.com

You might also like