Docker: Cheat Sheet

Docker: Cheat Sheet
Photo by Ian Taylor / Unsplash
  1. docker run : Create and start a new container from an image. Example: docker run ubuntu
  2. docker start : Start an existing container. Example: docker start my_container
  3. docker stop : Stop a running container. Example: docker stop my_container
  4. docker exec : Run a command inside a running container. Example: docker exec my_container bash
  5. docker ps : List all running containers.
  6. docker ps -a : List all containers, running and stopped.
  7. docker rm: Remove a container. Example: docker rm my_container
  8. docker images: List all images on the system.
  9. docker pull: Download an image from a registry. Example: docker pull ubuntu
  10. docker rmi: Remove an image. Example: docker rmi ubuntu
  11. docker logs: Show logs for a container. Example: docker logs my_container
  12. docker inspect : View detailed information about a container or image. Example: docker inspect my_container
  13. docker volume create : Create a new volume. Example: docker volume create my_volume
  14. docker volume ls : List all volumes
  15. docker volume rm : Remove a volume. Example: docker volume rm my_volume
  16. docker network create : Create a new network. Example: docker network create my_network
  17. docker network ls : List all networks
  18. docker network rm :  Remove a network. Example: docker network rm my_network
  19. docker run --name: Assign a name to a container at creation time. Example: docker run --name my_container ubuntu
  20. docker run -d : Run a container in detached mode.
  21. docker run -p : Publish a container's port(s) to the host. Example: docker run -p 8080:80 nginx
  22. docker run -e