Locating Docker Container Storage Paths on Linux
On Linux hosts, Docker persists container data within the host filesystem under the daemon's root directory, typically /var/lib/docker. This location houses image layers, container metadata, volumes, and network configurations.
To determine the current storage location and disk utilization:
df -h $(docker info -f '{{ .DockerRootDir }}')
Or inspect the directory contetns directly:
ls -la /var/lib/docker/
Within this directory, active containers store their writable layer contents in subdirectories managed by the storage driver (such as overlay2 or devicemapper). To identify a specific container's filesystem path:
docker inspect --format='{{ .GraphDriver.Data.MergedDir }}' <container_name>
For containers utilizing bind mounts or named volumes, locate the host-side source paths with:
docker inspect --format='{{range .Mounts}}{{.Type}}: {{.Source}} -> {{.Destination}}{{"\n"}}{{end}}' <container_name>
Practical demonstration:
# Launch a sample workload with volume attachment
docker run -d \
--name demo-app \
-v /opt/data:/app/data \
-p 8080:80 \
httpd:alpine
# Retrieve the container's root filesystem location
docker inspect --format='{{ .GraphDriver.Data.MergedDir }}' demo-app
# List volume mount mappings
docker inspect --format='{{range .Mounts}}Host: {{.Source}}, Container: {{.Destination}}{{end}}' demo-app
To examine the global volume storage directory:
docker volume inspect --format='{{ .Mountpoint }}' <volume_name>
This information assists in troubleshooting storage issues, performing manual backups of container data, or cleaning up orphaned layers when standard pruning commands prove insufficient.