๐ฏ Process Management
# Show all running docker containersdocker ps
# Show all docker containersdocker ps-a
# Run a containerdocker run <image>:<tag>
# Run a container and connect to itdocker run -it <image>>:<tag>
# Run a container in the backgrounddocker run-d <image>:<tag>
# Stop a containerdocker stop <container>
# Kill a containerdocker kill <container>
๐ฏ Images/Repository
# List available local imagesdocker images
# Search for docker imagesdocker search <image>
# Pull a docker imagedocker pull <image>
# Build an image with a dockerfiledocker build -t <image>:<tag> <run_directory> -f <dockerfile>
# Login to a remote repositorydocker login <repository>
# Push an image to your remote repositorydocker push <image>:<tag>
# Remove a local docker imagedocker rmi <image>:<tag>
# Show metadata for an imagedocker inspect <image>
# Remove all unused docker imagesdocker image prune
๐ฏ Volumes & Ports
# List volumesdocker volume ls
# Create a volumedocker volume create <volume>
# Delete a volumedocker volume rm <volume>
# Show volume metadatadocker volume inspect <volume>
# Delete all volumes not attached to a containerdocker volume prune
# Mount a local directory to your containerdocker run -v <local_dir>:<container_dir> <image>
# Copy file or folder from a docker container to host machinedocker cp <container>:<container_dir> <local_dir>
# Copy file or folder from local machine onto a containerdocker cp <local_dir> <container>:<container_dir>
# Map a local port to a docker instancedocker run-d-p
127.0.0.1
:<local_port>:<docker_port> <image>
# List the ports a docker container is running ondocker port <container>
๐ฏ Docker Compose
# Start your docker-compose defined resources in detached modedocker-compose up -d -f <docker_compose_yaml>
# Stop all docker-compose resourcesdocker-compose stop
# Destroy all docker-compose resourcesdocker-compose down
# Show docker-compose processesdocker-compose ps
# Show docker-compose logsdocker-compose logs
# Show docker-compose resource consumptiondocker-compose top
๐ฏ Troubleshooting
# Show the logs of a containerdocker logs <container>
# Follow/tail the logs of a containerdocker logs -f <container>
# Show timestamps on docker logsdocker logs -t <container>
# Show details/metadata of a containerdocker inspect <container>
# Show a 'top' view of processes running on a containerdocker top <container>
# Show a 'top' view of all docker containersdocker stats
# Show any files that have changed since startupdocker diff <container>
# Connect to an already running containerdocker attach <container>
# Execute a command on a containerdocker exec-it <container_id> /bin/bash
# Show docker system wide informationdocker system info
# Show docker disk space useddocker system df
Thank you for reading!