Key Docker Commands
| Command | Description |
|---|---|
docker start <name> | Start a container |
docker stop <name> | Stop a container |
docker restart <name> | Restart |
docker ps | Show running containers |
docker ps -a | All containers (incl. stopped) |
docker pull <image> | Pull latest image |
docker logs <name> | Show logs |
docker logs -f <name> | Follow logs live |
docker exec -it <name> bash | Open shell in container |
docker rm <name> | Remove container |
docker rmi <image> | Remove image |
docker system prune | Clean unused data |
docker system prune -a | Full cleanup (incl. images) |
Docker Compose – Orchestrating Your Stack
Docker Compose lets you manage multiple containers from a single YAML file. One command brings your entire stack up or down.
# Start stack (detached)
docker-compose up -d
# Stop and remove containers
docker-compose down
# Stop + delete volumes (CAUTION!)
docker-compose down -v
# Rebuild and restart
docker-compose up -d --build
# Update
docker-compose pull && docker-compose up -d
# Stream all logs
docker-compose logs -f
# Restart one service
docker-compose restart nextcloud-lisorect
# Clean unused data
docker system prune -aExample: compose.yaml (Nextcloud Stack)
services:
db:
image: mariadb:10.11
container_name: nextcloud-db
restart: unless-stopped
environment:
MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD}
MYSQL_DATABASE: ${MYSQL_DATABASE}
MYSQL_USER: ${MYSQL_USER}
MYSQL_PASSWORD: ${MYSQL_PASSWORD}
volumes:
- /volume1/docker/nextcloud_db_data:/var/lib/mysql
redis:
image: redis:7-alpine
container_name: nextcloud-redis
restart: unless-stopped
volumes:
- /volume1/docker/nextcloud_redis_data:/data
nextcloud-lisorect:
image: nextcloud:latest
container_name: nextcloud-lisorect
depends_on: [db, redis]
restart: unless-stopped
ports:
- "3001:80"
environment:
MYSQL_HOST: nextcloud-db
MYSQL_DATABASE: ${MYSQL_DATABASE}
MYSQL_USER: ${MYSQL_USER}
MYSQL_PASSWORD: ${MYSQL_PASSWORD}
REDIS_HOST: nextcloud-redis
volumes:
- /volume1/docker/nextcloud_config:/var/www/html/config
- /volume1/docker/nextcloud_data:/var/www/html/data