Skip to content

Instantly share code, notes, and snippets.

Last active July 13, 2021 18:41
What would you like to do?
Notes on docker

Docker notes:


Images - Stopped containers Containers - running containers


  • docker version
    • client (local machine)
    • server (docker)
  • docker info
    • additional info (more than version)
    • system info, number of containers, status of containers, etc.
  • docker ps
    • list currently running containers
  • docker ps -a
    • see recently run containers, but are now done
  • docker run <name of image>
    • run image (checks local first, then checks docker hub if not found local)
  • docker images
    • all images on local machine
  • docker pull <name>:<version>
    • pulls docker image off of docker hub (version optional)
  • docker rmi <name>:<tag>
    • remove image
    • you can get the name and tag from 'docker images' command
  • docker run -d --name web <image name to use>
    • -d start container in detached mode
    • --name : a name for the container
    • -p 80:8080 (web server) - map port 80 on host to port 8080 inside the container
    • - docker hub image or local image name
  • docker stop <name>
    • stops a container from running
  • docker start<name>
    • restart container
  • docker run -it --name <name> ubuntu:lastest /bin/bash
    • -it don't run in background, open in this terminal
  • docker build <context>
    • builds and image from a Dockerfile and a context
    • context can be a directory (possibly somethings else?)
    • -f flag to point to a directory in the file system containing the dockerfile
    • -t to save the built image (specifies the directory to save it to)
      • can specify multiple locations to copy it to
  • docker rmi $(docker images -f “dangling=true” -q)
    • Remove all <none> images
  • docker container prune
    • Remove all exited containers

Dockerfile Syntax/Format


# comment INSTRUCTION arguments

  • must start with a FROM instruction
    • specifies the base image
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment