Docker code snippets
31-08-2022
Docker commands
List information:
# list running containers
docker ps
# list stopped containers
docker ps -f "status=exited"
# list all containers
docker ps -a
# list all images
docker images -a
# list all volumes
docker volume ls
# list all dangling images (<none>)
docker images -f "dangling=true" -q
Remove resources:
# stop and remove all containers
docker stop $(docker ps -a -q)
docker rm $(docker ps -a -q)
# remove resources that are dangling (not tagged or associated with a container)
docker system prune
# remove any stopped containers and all unused images
docker system prune -a
# remove all images
docker rmi $(docker images -a -q)
# remove all volumes
docker volume prune
# remove all dangling images (<none>)
docker rmi $(docker images -f "dangling=true" -q)
Build images:
# build docker image with tag
docker build -t tag_name ./
# run docker container using a specified image
docker run --name mlmodels_container -p 80:80 mlmodels
# clean restart
docker-compose down
docker rm -fv $(docker ps -aq)
docker network prune
docker volume prune
docker system prune