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 <Network> Inspect a network
docker pull Downloads an image from Docker Hub docker network create <Network> Create a network
user/image
docker network rm <Network> Removes a network
docker login Authenticate to Docker Hub (or other Docker
docker network connect <Network> Connect a container to the
registry)
<Container> network
docker push Uploads an image to Docker Hub. You must be
docker network connect --ip <IP> Specify the IP address of
user/image⠀⠀⠀ authenticated to run this command
<Network> <Container> container interface
docker info Retrieves docker configuration
docker network disconnect <Networ‐ Disconnect container from
docker version Retrieves docker versioning k_Name> <Container> network
<Network> can be replaced with the network ID or NAME
Image and Container Information
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 <user>/<i‐ Lists the history of an image docker run -p <hostport‐ Run an image in detached mode with
mage> >:<containerport> -d port forwarding
docker logs <container> Displays the logs from a running user/image
container docker start <container> Start a container
docker port <container> Displays the exposed port of a running docker exec <container> Executes a command within a running
container [shell command] container, e.g. /bin/bash
docker diff <container> Lists the changes made to a container docker attach <containe‐ Changes the command prompt from the
docker logs [-f] <conta‐ Read container stdout r> host to a running container
iner> docker stop <container> Stop a container
docker top <container> Show running processes docker rm -f <container> Delete a container
docker inspect <conta‐ Show container configuration docker create <image>: Create image
iner> <tag>
docker events Show container events docker rmi <image> Delete an image
<container> can be replaced with container name or ID docker tag <user>/<i‐ Add a new tag to an image
mage>:<tag> <user>/<i‐
mage>:<new tag>
ctrl+p then ctrl+q Changes the command prompt from the
host to a running container
<container> 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 containterID userna‐ Commit from container
me/imagename to an image
docker push username/imagename Docker push example
(after logging)
docker run -it -v /host/directory:/contain‐ Mount a host directory in
er/directory [options] image [command] a Docker container
docker cp /host/directory/file.ext Copy file from host
container:/container/directory 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
--publish-all Publish all ports
-d, –-detach Run in background
-e, –-env Set env vars
-v, --volume Mount files or directories
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