Chat on WhatsApp
CR Guard
CloudRevol
← Back to Blog

Docker & Container Cheat Sheet

Docker Container Cheat Sheet

Learn the most useful Docker commands for managing containers, images, networking, volumes, Docker Compose deployments and production workloads.

In This Guide

✓ Install Docker
✓ Images
✓ Containers
✓ Logs
✓ Volumes
✓ Networks
✓ Docker Compose
✓ Troubleshooting
✓ Cleanup
✓ Best Practices

Install Docker

curl -fsSL https://get.docker.com | sudo bash
docker --version
docker info

Docker Images

docker images
docker pull nginx
docker pull ubuntu:24.04
docker image inspect nginx
docker rmi IMAGE_ID

Container Management

docker ps
docker ps -a
docker run -d nginx
docker start CONTAINER_ID
docker stop CONTAINER_ID
docker restart CONTAINER_ID
docker rm CONTAINER_ID

Access Container Shell

docker exec -it CONTAINER_ID bash
docker exec -it CONTAINER_ID sh

Logs & Monitoring

docker logs CONTAINER_ID
docker logs -f CONTAINER_ID
docker stats
docker top CONTAINER_ID

Volumes

docker volume ls
docker volume create mydata
docker volume inspect mydata
docker volume rm mydata

Docker Networking

docker network ls
docker network create mynetwork
docker network inspect mynetwork
docker network rm mynetwork

Docker Compose Example

services:

  app:
    image: nginx
    container_name: nginx-app

    ports:
      - "80:80"

    restart: unless-stopped

Docker Compose Commands

docker compose up -d
docker compose down
docker compose restart
docker compose logs -f

Docker Cleanup Commands

docker system prune -a
docker image prune
docker volume prune
docker network prune

Docker Best Practices

Use Official Images

Prefer official Docker Hub images whenever possible.

Keep Containers Stateless

Store data in volumes instead of containers.

Use Docker Compose

Manage multiple containers efficiently.

Monitor Resource Usage

Regularly review docker stats.

Frequently Asked Questions

What is Docker?

Docker is a containerization platform that allows applications and their dependencies to run consistently across development, testing and production environments.

What is the difference between Docker and a Virtual Machine?

Virtual machines include a full operating system, while Docker containers share the host kernel and are significantly lighter, faster and more resource efficient.

What is Docker Compose used for?

Docker Compose allows multiple containers to be defined and managed using a single YAML file, making application deployment much easier.

How do I view running Docker containers?

docker ps

This command displays all active containers running on the server.

How do I view Docker container logs?

docker logs CONTAINER_ID

Logs help troubleshoot application issues and monitor activity.

What are Docker Volumes?

Docker volumes provide persistent storage that survives container restarts and recreations, making them ideal for databases and application data.

What are Docker Networks?

Docker networks allow containers to communicate securely with each other while remaining isolated from external systems when required.

How do I restart a Docker container?

docker restart CONTAINER_ID

This safely restarts a running container.

Is Docker suitable for production environments?

Yes. Docker is widely used in production for hosting web applications, APIs, databases, microservices and DevOps workloads.

What are Docker best practices for production?

Use official images, configure restart policies, store persistent data in volumes, monitor resource usage, update images regularly and secure exposed ports.

Docker Compose or Kubernetes?

Docker Compose is ideal for small to medium deployments, while Kubernetes is better suited for large-scale container orchestration and enterprise environments.

Does Docker improve application performance?

Docker itself does not automatically make applications faster, but it improves deployment consistency, scalability and resource utilization.

Need Help Deploying Docker Containers?

CloudRevol provides managed cloud hosting, Docker deployments, monitoring, backups, free migration and expert support.