1.
Version and System Info
Command Description
docker --version Shows the installed Docker version
docker info Displays system-wide information about Docker
docker help Lists all available Docker commands
2. Working with Docker Images
Command Description
docker search <image-name> Searches Docker Hub for an image
docker pull <image-name> Pulls an image from Docker Hub
docker images Lists all images available locally
docker rmi <image-id> Removes a local image by its ID
docker image prune Removes unused images
docker build -t <name> <path> Builds an image from a Dockerfile and tags it
docker tag <image-id> <repo>:<tag> Tags an image for pushing to a registry
docker push <username/image-name> Pushes a tagged image to Docker Hub
3. Running Containers
Command Description
docker run <image-name> Runs a container from an image
docker run -it <image-name> Runs a container in interactive mode with terminal
docker run -d <image-name> Runs a container in detached (background) mode
docker run -p 8080:80 <image-name> Maps host port 8080 to container port 80
docker run --name <name> <image-name> Assigns a name to the running container
docker run -v <host-path>:<container-path> Mounts a host directory as a volume inside the
<image> container
docker run --rm <image-name> Automatically removes the container after it exits
4. Managing Containers
Command Description
docker ps Lists running containers
docker ps -a Lists all containers (including stopped)
docker start <container-id> Starts an existing container
docker stop <container-id> Gracefully stops a running container
docker restart <container-id> Restarts a container
docker kill <container-id> Forcefully stops a container
docker rm <container-id> Removes a stopped container
docker container prune Removes all stopped containers
5. Accessing Containers
Command Description
docker exec -it <container-id> bash Runs a bash shell inside a running container
docker attach <container-id> Attaches your terminal to a running container’s standard input/output
docker logs <container-id> Shows logs from a container
docker inspect <container-id> Displays detailed information about the container
7. Docker Volumes
Command Description
docker volume create <volume-name> Creates a named volume
docker volume ls Lists all volumes
docker volume inspect <volume-name> Displays volume details
docker volume rm <volume-name> Removes a volume
docker volume prune Deletes all unused volumes
8. Docker Networks
Command Description
docker network ls Lists all Docker networks
docker network inspect <name> Shows detailed network information
docker network create <name> Creates a custom network
docker network rm <name> Removes a Docker network