Skip to content
BotServBotServ
DockerCommandsCLIContainerCheat Sheet

Essential Docker Commands

Docker CLI quick reference. Containers, images, volumes, networks and Compose for local AI.

S

schutzgeist

3 min read
Essential Docker Commands

Essential Docker Commands

What this article covers

  • The most frequently used Docker commands for daily work.
  • Managing containers, images, volumes, and networks.
  • Docker Compose for multi-container setups.
  • Useful command sequences for local AI services.
  • Common pitfalls and tips.

Introduction: Essential Docker Commands

Docker is the standard tool for running applications in containers. For local AI services like Ollama, Open WebUI, OpenClaw, OpenHands, or databases, Docker plays a central role. Master the key commands, and you can quickly start services, monitor containers, manage images, and troubleshoot issues.

This article covers the essential Docker and Docker Compose commands you’ll use regularly in your homelab and AI workflows.

Key concepts

  • Image: A template for a container.
  • Container: A running instance of an image.
  • Volume: Persistent storage for containers.
  • Network: A virtual network for containers.
  • Registry: A storage location for images, such as Docker Hub.
  • Compose: A tool for multi-container applications.
  • Dockerfile: Instructions for building an image.

Managing containers

CommandPurpose
docker psList running containers.
docker ps -aList all containers, including stopped ones.
docker run <image>Start a container.
docker run -d --name my-container <image>Start a container in detached mode.
docker start <container>Start a container.
docker stop <container>Stop a container.
docker restart <container>Restart a container.
docker rm <container>Remove a container.
docker exec -it <container> /bin/bashEnter a running container shell.
docker logs <container>View logs.
docker logs -f <container>Follow logs in real time.

Examples:

docker run -d --name ollama -p 11434:11434 ollama/ollama
docker exec -it ollama /bin/bash
docker logs -f ollama

Managing images

CommandPurpose
docker imagesList local images.
docker pull <image>Download an image.
docker rmi <image>Delete an image.
docker build -t <name> .Build an image from a Dockerfile.
docker tag <source> <target>Tag an image.
docker push <image>Upload an image to a registry.

Examples:

docker pull ollama/ollama:latest
docker rmi ollama/ollama:latest

Managing volumes

CommandPurpose
docker volume lsList volumes.
docker volume create <name>Create a volume.
docker volume rm <name>Delete a volume.
docker volume inspect <name>Show volume details.

Example:

docker volume create ollama-data
docker run -d --name ollama -v ollama-data:/root/.ollama -p 11434:11434 ollama/ollama

Managing networks

CommandPurpose
docker network lsList networks.
docker network create <name>Create a network.
docker network inspect <name>Show network details.
docker network rm <name>Delete a network.

Docker Compose

CommandPurpose
docker compose upStart services from compose.yaml.
docker compose up -dStart services in the background.
docker compose downStop and remove services.
docker compose down -vRemove services and volumes.
docker compose psShow status.
docker compose logsView logs.
docker compose logs -fFollow logs in real time.
docker compose pullPull the latest images.
docker compose buildRebuild images.
docker compose restartRestart services.

Example:

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

System and resources

CommandPurpose
docker system dfShow storage usage.
docker system pruneRemove unused data.
docker system prune -aRemove all unused images and containers.
docker statsShow resource usage in real time.
docker top <container>Show processes in a container.

Useful command sequences

Start Ollama with Docker

docker run -d \
  --name ollama \
  --gpus all \
  -v ollama-data:/root/.ollama \
  -p 127.0.0.1:11434:11434 \
  ollama/ollama

Connect Open WebUI to Ollama

docker run -d \
  --name open-webui \
  -p 8080:8080 \
  -e OLLAMA_BASE_URL=http://host.docker.internal:11434 \
  -v open-webui:/app/backend/data \
  ghcr.io/open-webui/open-webui:main

Clean up containers

docker stop $(docker ps -q)
docker rm $(docker ps -aq)
docker system prune -f

Caution: docker system prune -a also removes unused images.

Tips

  • Assign container names so you don’t have to work with IDs.
  • Use volumes for persistent data.
  • Use docker compose instead of long docker run commands.
  • Run docker system prune regularly to clean up.
  • Use docker logs -f to troubleshoot issues.

Common pitfalls

  • Port already in use: Stop another container or choose a different host port.
  • Volume data missing: Volume was not mounted when starting the container.
  • GPU not detected: Forgot --gpus all or drivers are missing.
  • Container cannot reach host: Use host.docker.internal.
  • Image not found: Check the image name for typos or verify your internet connection.

Further reading and resources

FAQ: Docker commands

How do I see all running containers? Use docker ps.

How do I stop all containers? docker stop $(docker ps -q).

How do I delete all containers? docker rm $(docker ps -aq).

What’s the difference between docker and docker compose? Docker manages individual containers, while Compose manages multiple containers together.

How do I reach a container by its name? Within the same Docker network, use the container name, for example http://ollama:11434.

Sources and further reading

Summary: Essential Docker Commands

Docker is essential for local AI services. The most important commands are run, ps, start, stop, logs, exec, images, volume, and compose up/down. With just a few commands, you can start, monitor, and manage Ollama, Open WebUI, databases, and agents. Using Compose files makes your setups reproducible and easier to maintain.

Back to Blog
Share:

Related Posts