Skip to content

Instantly share code, notes, and snippets.

@Aphellirus
Last active July 29, 2021 08:10
Show Gist options
  • Save Aphellirus/f9880accc12cccfbd97a13ee2da92a1e to your computer and use it in GitHub Desktop.
Save Aphellirus/f9880accc12cccfbd97a13ee2da92a1e to your computer and use it in GitHub Desktop.
Docker Cheat sheet
Command Description
docker build -t myimage:1.0 Build an image from the Dockerfile in the current directory and tag the image
docker image ls List all images that are locally stored with the Docker Engine
docker image rm alpine:3.4 Delete an image from the local image store
Command Description
Ctrl-p + Ctrl-q Disconnects from current interactive container
docker ps Lists the current running containers
docker images Lists available containers
docker stop Stops the specified container
docker port Lists the ports exposed on the specified container
docker network inspect Displays the net information for the specified container
docker network ls Lists the available networks. The Network ID corresponds to the bridge interface on the host

All commands below are called as options to the base docker command. Run docker --help for more information on a particular command.

Command Description
app* Docker Application
assemble* Framework-aware builds (Docker Enterprise)
builder Manage builds
cluster Manage Docker clusters (Docker Enterprise)
config Manage Docker configs
context Manage contexts
engine Manage the docker Engine
image Manage images
network Manage networks
node Manage Swarm nodes
plugin Manage plugins
registry* Manage Docker registries
secret Manage Docker secrets
service Manage services
stack Manage Docker stacks
swarm Manage swarm
system Manage Docker
template* Quickly scaffold services (Docker Enterprise)
trust Manage trust on Docker images
volume Manage volumes
Command Description
docker container stop web Stop a running container through SIGTERM
docker container kill web Stop a running container through SIGKILL
docker network ls List the networks
docker container ls List the running containers (add --all to include stopped containers)
docker container rm -f $(docker ps -aq) Delete all running and stopped containers
docker container logs --tail 100 web Print the last 100 lines of a container’s logs
Command Description
docker pull myimage:1.0 Pull an image from a registry
docker tag myimage:1.0 myrepo/myimage:2.0 Retag a local image with a new image name and tag
docker push myrepo/myimage:2.0 Push an image to a registry
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment