# Help
docker --help # list of commands
docker «command» --help # information about command
docker --version # Docker version information
docker info # Docker system information
# Work with images
docker search debian # serach images by keyword "debian"
# download last version (default tag is "latest")
docker pull <IMAGE_NAME>
# download last version (latest) prometheus image
# from prom verndors repository docker.io/prom
docker pull prom/prometheus
# download from docker.io image ubuntu with tag 18.04
docker pull docker.io/library/ubuntu:18.04
docker images # list of local images
# Delete image. Type «image_name»:«tag» or «image_id».
# Before deleting image you should stop all containers, baset on that
docker rmi «image_name»:«tag»
docker rmi $(docker images -aq) # remove all images
# Work with continers
docker run hello-world # Hello, world! container
# run ubuntu container and execute command bash in interactive mode
docker run -it ubuntu bash
# run container "gettind-started" and map the hosts port 8080 to
# containers internal port 80
docker run --name docker-getting-started --publish 8080:80 docker/getting-started
# run container "mongodb" with name "mongodb" detached (deamon mode).
# remove all after stop!
docker run --detach --name mongodb docker.io/library/mongo:4.4.10
docker ps # show running containers
docker ps -a # show all containers
docker stats --no-stream # show statistics
docker start alpine # create container on image "alpine"
# Run container.
docker start «container_name»
docker start «container_id»
# Run all containers
docker start $(docker ps -a -q)
# Stop container
docker stop «container_name»
docker stop «container_id»
# stop all containers
docker stop $(docker ps -a -q)
# Delete container
docker rm «container_name»
docker rm <container_id>
# Remove all containers
docker rm $(docker ps -a -q)
# System
# System info
docker system info
# occupied disk space
docker system df
# remove unused data and clean disk
docker system prune -af
Full cheatsheet at https://dockerlabs.collabnix.com/docker/cheatsheet/