Docker Cheatsheet

// Docker & Docker Compose commands quick reference

docker run <image>Create and start a container
docker run -d <image>Run container in background (detached)
docker run -it <image> bashRun container with interactive shell
docker run -p 8080:80 <image>Map host port 8080 to container port 80
docker run -v /host:/container <image>Mount host directory as volume
docker run --name myapp <image>Run container with custom name
docker run -e VAR=value <image>Set environment variable
docker run --rm <image>Remove container when it stops
docker run --network <net> <image>Connect to a specific network
docker psList running containers
docker ps -aList all containers (including stopped)
docker stop <container>Stop a running container
docker start <container>Start a stopped container
docker restart <container>Restart a container
docker rm <container>Remove a stopped container
docker rm -f <container>Force remove a running container
docker exec -it <container> bashOpen shell in running container
docker logs <container>View container logs
docker logs -f <container>Follow container logs (tail)
docker inspect <container>Show detailed container info
docker statsShow live resource usage
docker top <container>Show running processes in container
docker cp <src> <container>:<dest>Copy files to/from container
docker imagesList local images
docker pull <image>Download image from registry
docker push <image>Upload image to registry
docker build -t <name> .Build image from Dockerfile
docker build --no-cache -t <name> .Build without using cache
docker tag <image> <new-tag>Tag an image
docker rmi <image>Remove an image
docker image pruneRemove unused images
docker save -o file.tar <image>Save image to tar file
docker load -i file.tarLoad image from tar file
docker history <image>Show image layer history
docker volume create <name>Create a named volume
docker volume lsList volumes
docker volume rm <name>Remove a volume
docker volume pruneRemove unused volumes
docker network create <name>Create a network
docker network lsList networks
docker network rm <name>Remove a network
docker network connect <net> <container>Connect container to network
docker network inspect <name>Show network details
docker compose upCreate and start all services
docker compose up -dStart services in background
docker compose up --buildBuild images then start services
docker compose downStop and remove containers, networks
docker compose down -vAlso remove volumes
docker compose psList compose services
docker compose logsView logs for all services
docker compose logs -f <service>Follow logs for a service
docker compose exec <service> bashOpen shell in service container
docker compose buildBuild or rebuild services
docker compose pullPull service images
docker compose restartRestart all services
docker compose stopStop services (without removing)
docker compose run <service> <cmd>Run one-off command in service
docker compose configValidate and view compose config
FROM <image>Set base image
WORKDIR /appSet working directory
COPY <src> <dest>Copy files from host to image
ADD <src> <dest>Copy files (supports URLs and tar extraction)
RUN <command>Execute command during build
CMD ["executable", "arg"]Default command when container starts
ENTRYPOINT ["executable"]Configure container as executable
ENV KEY=valueSet environment variable
EXPOSE <port>Document which ports are used
VOLUME ["/data"]Create mount point for volume
ARG <name>=<default>Build-time variable
LABEL key=valueAdd metadata to image
USER <user>Set user for subsequent commands
HEALTHCHECK CMD <command>Define container health check
.dockerignoreFile to exclude files from build context
docker system dfShow Docker disk usage
docker system pruneRemove unused data (containers, images, networks)
docker system prune -aRemove ALL unused data
docker container pruneRemove stopped containers
docker infoShow Docker system info
docker versionShow Docker version
docker loginLog in to Docker registry
docker logoutLog out from Docker registry

#About Docker Cheatsheet

Free online Docker cheatsheet. Quick reference for Docker and Docker Compose commands including container management, images, volumes, networks, and compose workflows. This tool runs entirely in your browser — your data is never sent to a server. Just paste your input, get instant results, and copy with one click. No sign-up or installation required.

#FAQ

What is the difference between Docker and Docker Compose?
Docker manages individual containers, while Docker Compose manages multi-container applications defined in a docker-compose.yml file. Compose simplifies running applications that require multiple services (e.g., web server + database + cache).
What is the difference between a Docker image and container?
An image is a read-only template containing the application code, runtime, libraries, and dependencies. A container is a running instance of an image. You can run multiple containers from the same image, each with its own isolated state.
</> Embed this tool

Copy this code to embed the tool on your website. Adjust the height to fit your layout.

<iframe src="https://www.browserutils.dev/embed/docker-cheatsheet" width="100%" height="500" frameborder="0" title="Docker Cheatsheet"></iframe>

#Related