Skip to content

Instantly share code, notes, and snippets.

@israeljrs
Created December 21, 2018 23:42
Show Gist options
  • Save israeljrs/34fa855e5a12136662ef8117e427d596 to your computer and use it in GitHub Desktop.
Save israeljrs/34fa855e5a12136662ef8117e427d596 to your computer and use it in GitHub Desktop.
Docker commands
  1. Show all images docker images

  2. Show all running containers docker ps

  3. Show all running and stopped containers docker ps -a

  4. Run an container docker run image-name

  5. Run an container in detached mode docker run -d image-name

  6. Stop all running containers docker kill $(docker ps -q)

  7. Delete all stopped containers docker rm $(docker ps -a -q)

  8. Delete all images docker rmi $(docker images -q)

  9. Force delete images docker rmi -f $(docker images -q)

  10. Port mapping docker run -p host_port:docker_port image-name

  11. Volume mapping docker run -v host_volume:docker_volume image-name

  12. Run commands inside container docker exec container-id command

  13. Go inside container docker exec -it container-id bash

  14. Inspect a container (eg. to find internal ip of container, image it is using etc) docker inspect container-id

  15. View all networks docker network ls

  16. Delete a network docker network rm netowork-name

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment