Skip to content

Instantly share code, notes, and snippets.

@bradwestfall
Last active January 15, 2018 18:50
Show Gist options
  • Save bradwestfall/64ec914dcdd9fce3724dfeea21c2eece to your computer and use it in GitHub Desktop.
Save bradwestfall/64ec914dcdd9fce3724dfeea21c2eece to your computer and use it in GitHub Desktop.
Docker Cheat Sheet
# Build a container from a local Dockerfile
# 1. -t is the tagname
# 2. The appname is any name we want to distinguish containers
# 3. . the path to Dockerfile
docker build -t <appname> .
# List Images
docker images
# Remove an Image
docer rmi <imageid> <imageid>
docer rmi <appname> <appname>
# Remove All Images
docker rmi $(docker images -a -q)
# Run a container (also creates a container if it doesn't exist)
docker run <appname>
# Or, with more settings
# -d detached mode
# -rm remove the container after it's exited
docker run -p 3000:3000 -d -rm <appname>
# Show running containers
docker ps -a
# To stop, start, or remove an existing container that was created with docker run
docker stop <containerid>
docker start <containerid>
docker rm <containerid>
# To Remove all containers
docker rm $(docker ps -a -q)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment