Docker Cheat Sheet

Docker Cheat Sheet

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