Common Issues and Solutions (+1)
Common Issues and Solutions
Container won't start:
# Check logs
docker logs container-name
# Check container status
docker inspect container-name
# Run interactively to debug
docker run -it --entrypoint sh image-name
Permission denied errors:
# Fix file ownership
docker run --rm -v $(pwd):/app alpine chown -R $(id -u):$(id -g) /app
# Or use user namespace remapping
Out of disk space:
# Clean up unused resources
docker system prune -a --volumes
# Check disk usage
docker system df
Slow builds:
# Enable BuildKit
export DOCKER_BUILDKIT=1
# Use cache mounts
RUN --mount=type=cache,target=/root/.cache/pip pip install -r requirements.txt
Network connectivity issues:
# Check network
docker network inspect bridge
# Test connectivity
docker exec container-name ping other-container
# Check DNS resolution
docker exec container-name nslookup service-name
Debug Commands
# Shell into running container
docker exec -it container-name sh
# Copy files from container
docker cp container-name:/app/logs ./logs
# View container processes
docker top container-name
# Monitor resource usage
docker stats
# View container changes
docker diff container-name
# Export container filesystem
docker export container-name > container.tar