Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
5 views3 pages

Docker Commands

The document provides a comprehensive list of Docker commands categorized into general commands, image commands, container commands, network commands, volume commands, Docker Compose commands, system commands, registry commands, inspect commands, and tagging/versioning commands. Each category includes specific commands with brief descriptions of their functions. This serves as a quick reference guide for users to manage Docker effectively.

Uploaded by

wytudo
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views3 pages

Docker Commands

The document provides a comprehensive list of Docker commands categorized into general commands, image commands, container commands, network commands, volume commands, Docker Compose commands, system commands, registry commands, inspect commands, and tagging/versioning commands. Each category includes specific commands with brief descriptions of their functions. This serves as a quick reference guide for users to manage Docker effectively.

Uploaded by

wytudo
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 3

docker_commands = """

# General Docker Commands


# -------------------------
# Check Docker Version
docker --version

# Check Docker Info (details about the Docker system)


docker info

# Docker Image Commands


# ----------------------
# List all Docker Images
docker images

# Pull an Image from Docker Hub (e.g., PostgreSQL image)


docker pull postgres

# Build an Image from a Dockerfile


docker build -t my-image .

# Remove an Image
docker rmi <image_id_or_name>

# Tag an Image (for versioning or renaming)


docker tag <image_id_or_name> <new_name>:<tag>

# Search for an Image on Docker Hub


docker search <image_name>

# Docker Container Commands


# -------------------------
# List Running Containers
docker ps

# List All Containers (including stopped ones)


docker ps -a

# Run a New Container


docker run --name <container_name> -d <image_name>

# Example:
docker run --name my-postgres -e POSTGRES_PASSWORD=mysecretpassword -d postgres

# Stop a Running Container


docker stop <container_name_or_id>

# Start a Stopped Container


docker start <container_name_or_id>

# Restart a Container
docker restart <container_name_or_id>

# Remove a Container (stopped containers)


docker rm <container_name_or_id>

# Exec into a Running Container (enter container's shell)


docker exec -it <container_name_or_id> bash
# For a MongoDB container:
docker exec -it my-mongo bash

# Check Logs of a Running Container


docker logs <container_name_or_id>

# View Running Container's Resource Usage (CPU, Memory, etc.)


docker stats

# Docker Network Commands


# -----------------------
# List Docker Networks
docker network ls

# Create a New Docker Network


docker network create <network_name>

# Inspect a Docker Network (view details of a network)


docker network inspect <network_name>

# Remove a Docker Network


docker network rm <network_name>

# Docker Volume Commands(BIND mount and volumes)


# ----------------------
# List Docker Volumes
docker volume ls

# Create a Docker Volume


docker volume create <volume_name>

# Inspect a Docker Volume


docker volume inspect <volume_name>

# Remove a Docker Volume


docker volume rm <volume_name>

# Docker Compose Commands (for multi-container apps)


# --------------------------------------------------
# Start Services (based on a docker-compose.yml file)
docker-compose up

# You can add the -d flag to run it in the background:


docker-compose up -d

# Stop Services
docker-compose down

# View the Logs of Services


docker-compose logs

# Build Services (from the docker-compose.yml file)


docker-compose build
# Docker System Commands
# -----------------------
# Remove Unused Docker Objects (containers, images, volumes, networks)
docker system prune

# Remove All Stopped Containers, Unused Networks, and Unused Images


docker system prune -a

# Clean Up All Unused Volumes


docker volume prune

# Docker Registry Commands


# -------------------------
# Login to Docker Hub (or another registry)
docker login

# Push an Image to a Docker Registry (e.g., Docker Hub)


docker push <username>/<image_name>:<tag>

# Pull an Image from a Docker Registry


docker pull <username>/<image_name>:<tag>

# Docker Inspect Commands


# -----------------------
# Inspect a Container (get detailed info)
docker inspect <container_name_or_id>

# Inspect an Image (get detailed info about an image)


docker inspect <image_name_or_id>

# Docker Tagging and Versioning


# ----------------------------
# Tag an Image with a New Version
docker tag <image_name>:<tag> <new_image_name>:<new_tag>

# Remove an Image by ID or Name


docker rmi <image_name_or_id>

"""

You might also like