Docker Cheatsheet
Last modified: 16 Mar, 2020Managing Container
create
$ docker create -t -i fedora bash
start
$ docker start -a -i dff32a272ad4c
rename
$ docker rename my_container my_new_container
run
$ docker run -it ubuntu-ssh-k /bin/bash
delete
$ docker rm myfedora
update
$ docker update --cpu-shares 512 -m 300M dff32a272ad4 happy_kare
$ docker start
$ docker stop
$ docker restart
$ docker pause
$ docker unpause
$ docker wait
$ docker kill
$ docker attach
$ docker exec -i -t my-nginx-1 /bin/bash
Container information
$ docker ps
$ docker ps -a
View a list of all Docker container IDs
$ docker container ls -aq
$ docker logs
$ docker inspect --format '{{ .NetworkSettings.IPAddress }}' $(docker ps -q)
$ docker events
$ docker port
$ docker top
$ docker stats
$ docker diff
Managing Images
$ docker images
$ docker import
$ docker build
$ docker commit
$ docker rmi
$ docker load
$ docker save
$ docker history
$ docker tag
Manage Network
$ docker network create
$ docker network rm
$ docker network ls
$ docker network inspect
$ docker network connect
$ docker network disconnect
Using Repository
$ docker login --username=
$ docker logout
$ docker search mysql
$ docker pull ubuntu
$ docker push
Cleanup
Stop all Docker containers
$ docker stop $(docker ps -a -q)
Remove all Docker containers
$ docker rm $(docker ps -a -q)
Prune unused docker networks
$ docker network prune
$ docker container stop $(docker container ls -a -q -f "label=io.confluent.docker")
Stop the containers and prune the Docker system
-- Running these commands deletes containers, networks, volumes, and images; freeing up disk space
$ docker container stop $(docker container ls -a -q -f "label=io.confluent.docker") && docker system prune -a -f --volumes