Docker commands cheat-sheet
Docker docs and manuals
Run busybox inside docker-compose
| docker run --rm -it --network <NETWORK_NAME> busybox
|
Containers
docker container ls # docker ps
docker container top {cont_name} # top command for cont
docker container inspect {cont_name} # json with all cont parameters
docker container inspect {cont_name} --format '{{ .NetworkSettings.IPAddress}}'
docekr container stats # like watch command but for containers
docker container start # start stopped cont
docker container post {cont_name} # shows shared ports
Network
docker network ls
docker network inspect {network_name}
docker network create --driver
docker network connect {network_name}
docker network disconnect {network_name}
Reset
Delete all running and stopped containers
docker container rm -f $(docker ps -aq)
Unused cont prune on current host
docker system prune --all --force --volumes
Full docker prune on current host
docker stop $(docker container ls -a -q) && docker system prune -a -f --volumes
Print last container’s logs
docker container logs --tail 100 web
Export container filesystem to archive and chroot it
docker export <cont_name> /tmp/docker_archive.tar
cd /tmp
tar -xf docker_archive.tar
sudo chroot .