Skip to content

Docker

Basic Commands

Command Description
docker version Show Docker version information
docker info Show system-wide information about Docker
docker help Show help for a Docker command
docker run <image> Run a Docker container
docker ps Show running containers
docker ps -a Show all containers (running and stopped)
docker start <container> Start a stopped container
docker stop <container> Stop a running container
docker rm <container> Remove a stopped container
docker images Show available images
docker rmi <image> Remove an image
docker pull <image> Pull an image from a registry
docker push <image> Push an image to a registry

Container Management

Command Description
docker run -d <image> Run a container in detached mode
docker run -it <image> Run a container in interactive mode
docker exec <container> <command> Run a command inside a running container
docker stop -t <seconds> <container> Stop a container with a grace period
docker pause <container> Pause a running container
docker unpause <container> Unpause a paused container
docker restart <container> Restart a running container
docker logs <container> Show logs from a container
docker inspect <container> Show low-level information about a container
docker top <container> Show running processes inside a container
docker stats <container> Show real-time resource usage for a container
docker attach <container> Attach to a running container
docker wait <container> Wait for a container to exit
docker kill <container> Kill a running container

Image Management

Command Description
docker build <directory> Build an image from a Dockerfile
docker build -t <tag> <directory> Build an image with a tag
docker build -f <Dockerfile> <directory> Build an image from a specific Dockerfile
docker commit <container> <repository> Create an image from a running container
docker tag <source> <destination> Tag an image
docker save <image> > <file> Save an image to a file
docker load < <file> Load an image from a file
docker history <image> Show the history of an image
docker inspect <image> Show low-level information about an image
docker search <term> Search for an image on Docker Hub

Networking

Command Description
docker network ls List networks
docker network create <name> Create a network
docker network rm <name> Remove a network
docker network inspect <name> Show low-level information about a network
docker network connect <network> <container> Connect a container to a network
docker network disconnect <network> <container> Disconnect a container from a network
docker port <container> Show public-facing port of a container
docker run -p <host_port>:<container_port> <image> Publish a container's port to the host

Volume Management

Command Description
docker volume ls List volumes
docker volume create <name> Create a volume
docker volume rm <name> Delete a volume