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
| Command | Purpose |
|---|---|
docker ps | List running containers. |
docker ps -a | List 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/bash | Enter 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
| Command | Purpose |
|---|---|
docker images | List 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
| Command | Purpose |
|---|---|
docker volume ls | List 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
| Command | Purpose |
|---|---|
docker network ls | List networks. |
docker network create <name> | Create a network. |
docker network inspect <name> | Show network details. |
docker network rm <name> | Delete a network. |
Docker Compose
| Command | Purpose |
|---|---|
docker compose up | Start services from compose.yaml. |
docker compose up -d | Start services in the background. |
docker compose down | Stop and remove services. |
docker compose down -v | Remove services and volumes. |
docker compose ps | Show status. |
docker compose logs | View logs. |
docker compose logs -f | Follow logs in real time. |
docker compose pull | Pull the latest images. |
docker compose build | Rebuild images. |
docker compose restart | Restart services. |
Example:
docker compose up -d
docker compose logs -f
docker compose down
System and resources
| Command | Purpose |
|---|---|
docker system df | Show storage usage. |
docker system prune | Remove unused data. |
docker system prune -a | Remove all unused images and containers. |
docker stats | Show 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 composeinstead of longdocker runcommands. - Run
docker system pruneregularly to clean up. - Use
docker logs -fto 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 allor 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
- BotServ.de Docker Basics
- BotServ.de Ollama Features
- BotServ.de Open WebUI Administration
- BotServ.de Proxmox LXC vs. VM
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
- Docker Docs: https://docs.docker.com/
- Docker Compose: https://docs.docker.com/compose/
- Docker Hub: https://hub.docker.com/
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.


