Skip to content

Instantly share code, notes, and snippets.

@normanlolx
Created January 12, 2018 13:13
Show Gist options
  • Save normanlolx/a6d1ae5af15016e559d88d2e6f43c65d to your computer and use it in GitHub Desktop.
Save normanlolx/a6d1ae5af15016e559d88d2e6f43c65d to your computer and use it in GitHub Desktop.
Docker beginner commands
# List containers
docker ps
# List images
docker images
# Stop and delete all containers
docker stop $(docker ps -a -q)
docker rm $(docker ps -a -q)
# Delete all images (free up disk space)
docker rmi $(docker images -q)
# Stop, delete containers and remove images one-liner
docker stop $(docker ps -a -q) && docker rm $(docker ps -a -q) && docker rmi $(docker images -q)
# Build an image from a Dockerfile
docker build
# Run a command in a new container
docker run
# Run a command in a running container
docker exec
# Create and start containers
docker-compose up
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment