ADVANCED DOCKER COMMAND CHEAT SHEET

Vineet Kumar
1 min readFeb 3, 2020

--

  1. Remove all images :
    docker rmi $(docker images -q)
  2. Remove all running containers:
    docker rm -f $(docker ps -q)
  3. Remove all Containers:
    docker rm -f $(dcoker ps -aq)
  4. Remove all dangling (unused) container and images:
    docker system prune -a
  5. Create volume :
    docker volume create
  6. List volume:
    docker volume ls
  7. Remove Volume:
    docker volume rm
  8. Inspect Volume:
    docker volume inspect
  9. Remove Stop Containers:
    docker rm $(docker ps -q -f “status=exited”)
  10. Push an image to a registry:
    docker push [registry]/[reponame]/<image-name>:[tag]
  11. Run a detached container in a previously created container network:
    $ docker network create mynetwork & $ docker run --name mywildfly-net -d --net mynetwork \ -p 8080:8080 jboss/wildfly
  12. Push an image to a registry:
    docker push [registry]/[repo-name]/<image-name>:[tag]
  13. Build Image with different dockerfile name:
    docker build -t test -f diffrent_Docker_file .
  14. To Find images in docker local Registry server
    curl -k <IP>:5000/v2/_catalog
  15. Remove images based on repo fuzzy matching
    docker image prune --force --filter "repository=example.com*"
    Or maybe I want it based on image name
    Remove images based on image name fuzzy matching
    docker image prune --force --filter "repository=*example_product*"
  16. Save and load all docker images
    $docker save $(docker images --format '{{.Repository}}:{{.Tag}}') -o allinone.tar
    docker load -i allinone.tar

17. Add host in container:use --add-host domain-name:ip

--

--

No responses yet