Skip to content

Docker

Cheatsheet for Docker

Table of contents
  1. Cheatsheet for Docker
  2. Account commands
  3. Basic Commands
  4. Tagging example
  5. Container Commands
  6. Cleaning Up

Account commands

  • docker login - Register or log in to a Docker registry
  • docker logout - Log out from a Docker registry

Basic Commands

  • docker pull - Pull image or repository from a Docker registry
  • docker push - Push an image or repository to a Docker registry
  • docker tag [IMAGE] [NAME:TAG] - Tag a docker image with name and chosen tag
  • docker build [PATH | URL] - Build an image from a Dockerfile located in PATH or URL
  • docker images - List all Docker images
  • docker ps - List all Docker containers

Tagging example

docker tag <image hash> <dockerhub repo/name>:latest
docker push <dockerhub repo/name>:latest

Container Commands

  • docker cp [LOCAL PATH] [CONTAINER:DEST_PATH - Copy files from host to Docker container
  • docker cp [CONTAINER:PATH] [LOCAL PATH] - Copy files from Docker container to local path
  • docker attach CONTAINER - Attach local standard input, ouput and error streams to a running Docker container
  • docker run - Run a command in a new Docker container
  • docker start - Start one or more stopped Docker containers
  • docker stop - Stop a running Docker container

Cleaning Up

  • docker rmi - Remove one or more images
  • docker rm - Remove one or more containers
  • docker system prune - Remove unused data
  • docker system prune -a - Remove all unused images