Docker

Docker is a platform for developing, shipping, and running applications in containers. It enables you to separate your applications from your infrastructure so you can deliver software quickly.

Docker Version

Docker

Display Docker version information

docker --version

Docker Info

Docker

Display system-wide information about Docker

docker info

List Docker Images

Docker

List all Docker images

docker images

Pull Docker Image

Docker

Pull an image from a registry

docker pull image_name:tag

Remove Docker Image

Docker

Remove an image

docker rmi image_name:tag

Remove All Unused Images

Docker

Remove all unused images

docker image prune -a

Build Docker Image

Docker

Build an image from a Dockerfile

docker build -t image_name:tag .

Build Docker Image (No Cache)

Docker

Build an image from a Dockerfile without using cache

docker build --no-cache -t image_name:tag .

List Running Containers

Docker

List running containers

docker ps

List All Containers

Docker

List all containers (including stopped ones)

docker ps -a

Run Docker Container

Docker

Run a container in detached mode

docker run -d --name container_name image_name:tag

Run Docker Container (Interactive)

Docker

Run a container in interactive mode with a shell

docker run -it --name container_name image_name:tag /bin/bash

Run Docker Container (With Port Mapping)

Docker

Run a container with port mapping

docker run -d -p 8080:80 --name container_name image_name:tag

Run Docker Container (With Volume)

Docker

Run a container with a volume mount

docker run -d -v /host/path:/container/path --name container_name image_name:tag

Run Docker Container (With Environment Variables)

Docker

Run a container with environment variables

docker run -d -e "KEY=value" --name container_name image_name:tag

Stop Docker Container

Docker

Stop a running container

docker stop container_name

Start Docker Container

Docker

Start a stopped container

docker start container_name

Restart Docker Container

Docker

Restart a container

docker restart container_name

Remove Docker Container

Docker

Remove a container

docker rm container_name

Remove Running Docker Container

Docker

Force remove a running container

docker rm -f container_name

Remove All Stopped Containers

Docker

Remove all stopped containers

docker container prune

View Container Logs

Docker

View logs of a container

docker logs container_name

View Container Logs (Follow)

Docker

Follow logs of a container

docker logs -f container_name

Execute Command in Container

Docker

Execute a command in a running container

docker exec -it container_name /bin/bash

Copy File from Container

Docker

Copy a file from a container to the host

docker cp container_name:/container/path /host/path

Copy File to Container

Docker

Copy a file from the host to a container

docker cp /host/path container_name:/container/path

Inspect Container

Docker

Display detailed information about a container

docker inspect container_name

View Container Resource Usage

Docker

Display resource usage statistics for containers

docker stats

View Container Resource Usage (One Container)

Docker

Display resource usage statistics for a specific container

docker stats container_name

List Docker Networks

Docker

List all Docker networks

docker network ls

Create Docker Network

Docker

Create a Docker network

docker network create network_name

Connect Container to Network

Docker

Connect a container to a network

docker network connect network_name container_name

Disconnect Container from Network

Docker

Disconnect a container from a network

docker network disconnect network_name container_name

Remove Docker Network

Docker

Remove a Docker network

docker network rm network_name

Inspect Docker Network

Docker

Display detailed information about a network

docker network inspect network_name

List Docker Volumes

Docker

List all Docker volumes

docker volume ls

Create Docker Volume

Docker

Create a Docker volume

docker volume create volume_name

Remove Docker Volume

Docker

Remove a Docker volume

docker volume rm volume_name

Remove All Unused Volumes

Docker

Remove all unused volumes

docker volume prune

Inspect Docker Volume

Docker

Display detailed information about a volume

docker volume inspect volume_name

Docker Compose Up

Docker

Start services defined in docker-compose.yml

docker-compose up -d

Docker Compose Down

Docker

Stop and remove services defined in docker-compose.yml

docker-compose down

Docker Compose Build

Docker

Build services defined in docker-compose.yml

docker-compose build

Docker Compose Logs

Docker

View logs of services defined in docker-compose.yml

docker-compose logs

Docker Compose Logs (Follow)

Docker

Follow logs of services defined in docker-compose.yml

docker-compose logs -f

Docker Compose Ps

Docker

List containers for services defined in docker-compose.yml

docker-compose ps

Docker Compose Exec

Docker

Execute a command in a service defined in docker-compose.yml

docker-compose exec service_name command

Docker Compose Restart

Docker

Restart services defined in docker-compose.yml

docker-compose restart

Docker Compose Pull

Docker

Pull images for services defined in docker-compose.yml

docker-compose pull

Docker System Prune

Docker

Remove all unused containers, networks, images, and volumes

docker system prune

Docker System Prune (All)

Docker

Remove all unused containers, networks, images, and volumes (including unused images)

docker system prune -a

Docker System DF

Docker

Display Docker disk usage

docker system df

Docker Login

Docker

Log in to a Docker registry

docker login

Docker Logout

Docker

Log out from a Docker registry

docker logout

Docker Tag

Docker

Tag an image

docker tag source_image:tag target_image:tag

Docker Push

Docker

Push an image to a registry

docker push image_name:tag