Docker: Cheat Sheet
Last updated on
docker run
: Create and start a new container from an image. Example: docker run ubuntu
docker start
: Start an existing container. Example: docker start my_container
docker stop
: Stop a running container. Example: docker stop my_container
docker exec
: Run a command inside a running container. Example: docker exec my_container bash
docker ps
: List all running containers.docker ps -a
: List all containers, running and stopped.docker rm
: Remove a container. Example: docker rm my_container
docker images
: List all images on the system.docker pull
: Download an image from a registry. Example: docker pull ubuntu
docker rmi
: Remove an image. Example: docker rmi ubuntu
docker logs
: Show logs for a container. Example: docker logs my_container
docker inspect
: View detailed information about a container or image. Example: docker inspect my_container
docker volume create
: Create a new volume. Example: docker volume create my_volume
docker volume ls
: List all volumesdocker volume rm
: Remove a volume. Example: docker volume rm my_volume
docker network create
: Create a new network. Example: docker network create my_network
docker network ls
: List all networksdocker network rm
: Remove a network. Example: docker network rm my_network
docker run --name
: Assign a name to a container at creation time. Example: docker run --name my_container ubuntu
docker run -d
: Run a container in detached mode.docker run -p
: Publish a container's port(s) to the host. Example: docker run -p 8080:80 nginx
docker run -e