Docker Day-to-Day Operational Tasks
1. Cleaning Up Resources
- Pruning: Regularly remove unused data to free up disk space.
docker system prune -a: Removes stopped containers, unused networks, and unused images (be careful!).
docker volume prune: Removes unused volumes.
2. Debugging Containers
- Logs: Check the output of a container.
docker logs -f <container_id>: Follow the logs in real-time.
- Inspect: View detailed configuration (IP address, mounts, env vars).
docker inspect <container_id>
- Shell Access: Get inside a running container to troubleshoot.
docker exec -it <container_id> /bin/sh (or /bin/bash).
3. Image Management
- Pulling/Pushing:
docker pull <image>:<tag>: Download an image.
docker push <registry>/<image>:<tag>: Upload an image.
- Tagging:
docker tag <source_image> <target_image>: Create a new tag for an image (e.g., tagging myapp:latest as myapp:v1.0).
4. Resource Monitoring
- Stats: View live CPU and memory usage of running containers.