Docker Cheat Sheet

Rajat ChauhanRajat Chauhan
3 min read

COMMAND

USE

 sudo apt-get update
sudo apt install docker.io

Update libraries
Install Docker

 docker ps

List running container

 docker ps -a

List all the container

 docker pull

pull an image from a registry

 docker push

Push an image to a registry

 docker images

List available images

docker run

run a container from an image
docker run img_name:tag || docker run mysql:latest

        -  we can define name by --name

 docker stop <container_ID>

Stop the running container

 docker restart <container_ID>

Restart the container

 docker start <container_ID>

Start the container

 docker pause <container_ID>

Pause the container

 docker unpause <container_ID>

Unpause the container

 docker rm <container_ID>

Remove a container

 docker rmi <image_ID>

Remove image

 docker kill <container_ID>

Send a signal to a container to stop it abruptly

 docker build

Build an image from a Dockerfile
"docker build -t java-app:latest ."

 docker volume ls

List available volumes

 docker volume create <name>

Create volume
"docker volume create mysql-data"

 docker volume inspect <name>

Show information of the volume
"docker volume inspect mysql-data"

 docker volume rm

Remove the volume

 docker network ls

List all docker network
        - Bridge -> default n/w

 docker network create <name>

create new network || user defined bridge
"docker network create two-tier"

 docker network connect

Connect a container to a network

 docker network disconnect

Disconnect a container from a network

 docker port

Show mapped ports of a container

 docker logs

Show the logs of a container

 docker exec

execute a command inside a running container

 docker inspect

Show information about a container

 docker cp

Copy files between a container and the host

 docker commit

Create a new image from a container's changes

 docker login

Log in to a registry

 docker logout

Log out of the registry

 docker tag

Tag an image with a new name

 docker export

Export the contents of a container as a tar archive

 docker import

create a new image from a tar archive

 docker save

save an image as a tar archive

 docker load

load an image from a tar archive

 docker top

show the processes running inside a container

 docker stats

show resource usage statistics of containers

 docker diff

show the changes made to a container's filesystem

 docker events

show the events generated by Docker

 docker history

show the history of an image

 docker wait

wait for a container to exit and return its exit code

 docker attach

attach to a running container's console

 docker buildx

build and push multi-platform images

 docker compose

manage multi-container applications with Docker Compose

 docker swarm

create and manage a cluster of Docker nodes

 docker system prune

create and manage a cluster of Docker nodes

 docker system df

 show the usage of Docker objects

 docker system events

show the events generated by Docker on the system

 docker system info

show the system-wide information about Docker

 docker system inspect

 show detailed information about Docker objects

 docker system logs

 show the system logs of the Docker

 docker system version

show the version of Docker installed on the system

0
Subscribe to my newsletter

Read articles from Rajat Chauhan directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Rajat Chauhan
Rajat Chauhan

Rajat Chauhan is a skilled Devops Engineer, having experience in automating, configuring, deploying releasing and monitoring the applications on cloud environment. • Good experience in areas of DevOps, CI/CD Pipeline, Build and Release management, Hashicorp Terraform, Containerization, AWS, and Linux/Unix Administration. • As a DevOps Engineer, my objective is to strengthen the company’s applications and system features, configure servers and maintain networks to reinforce the company’s technical performance. • Ensure that environment is performing at its optimum level, manage system backups and provide infrastructure support. • Experience working on various DevOps technologies/ tools like GIT, GitHub Actions, Gitlab, Terraform, Ansible, Docker, Kubernetes, Helm, Jenkins, Prometheus and Grafana, and AWS EKS, DevOps, Jenkins. • Positive attitude, strong work ethic, and ability to work in a highly collaborative team environment. • Self-starter, Fast learner, and a Team player with strong interpersonal skills • Developed shell scripts (Bash) for automating day-to-day maintenance tasks on top of that have good python scripting skills. • Proficient in communication and project management with good experience in resolving issues.