I have encountered some weird behavior with Docker bind mounts that I do not understand. I hope someone can explain this to me.
When I run du -h /
on my host, I get:
Filesystem Size Used Available Use% Mounted on
overlay 19.7G 1.3G 17.4G 7% /
tmpfs 495.4M 259.9M 235.6M 52% /home/docker
But docker run -v /:/mnt/root alpine:latest df -h /mnt/root
gives me:
Filesystem Size Used Available Use% Mounted on
tmpfs 495.4M 259.9M 235.6M 52% /mnt/root
While the mount contents seem to be right, my expectation was that the mount will have the same size as the source.
Note that my host is actually a docker container that has a bind mount on the real host’s docker socket.
Output of docker version
Client:
Version: 17.10.0-ce
API version: 1.33
Go version: go1.8.3
Git commit: f4ffd2511c
Built: Wed Oct 18 00:21:18 2017
OS/Arch: linux/amd64
Server:
Version: 17.10.0-ce
API version: 1.33 (minimum version 1.12)
Go version: go1.8.3
Git commit: f4ffd2511c
Built: Wed Oct 18 00:26:36 2017
OS/Arch: linux/amd64
Experimental: true
Output of docker info
Containers: 19
Running: 6
Paused: 0
Stopped: 13
Images: 7
Server Version: 17.10.0-ce
Storage Driver: overlay2
Backing Filesystem: extfs
Supports d_type: true
Native Overlay Diff: true
Logging Driver: awslogs
Cgroup Driver: cgroupfs
Plugins:
Volume: local
Network: bridge host ipvlan macvlan null overlay
Log: awslogs fluentd gcplogs gelf journald json-file logentries splunk syslog
Swarm: active
NodeID: y95v7q3pc1kpph1jntq8fdjws
Is Manager: true
ClusterID: z9iidiwwx4nh0x7h411832g1e
Managers: 1
Nodes: 5
Orchestration:
Task History Retention Limit: 5
Raft:
Snapshot Interval: 10000
Number of Old Snapshots to Retain: 0
Heartbeat Tick: 1
Election Tick: 3
Dispatcher:
Heartbeat Period: 5 seconds
CA Configuration:
Expiry Duration: 3 months
Force Rotate: 0
Autolock Managers: false
Root Rotation In Progress: false
Node Address: 172.31.31.22
Manager Addresses:
172.31.31.22:2377
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: 06b9cb35161009dcb7123345749fef02f7cea8e0
runc version: 0351df1c5a66838d0c392b4ac4cf9450de844e2d
init version: 949e6fa
Security Options:
seccomp
Profile: default
Kernel Version: 4.9.52-moby
Operating System: Alpine Linux v3.5
OSType: linux
Architecture: x86_64
CPUs: 1
Total Memory: 990.9MiB
Name: ip-172-31-31-22.eu-central-1.compute.internal
ID: TI4N:CZ36:ISRI:RNNO:OUCQ:67VA:SDUE:NEDB:DYQY:YWPO:LDQA:ZKEN
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): true
File Descriptors: 94
Goroutines: 186
System Time: 2017-12-11T11:14:40.828251573Z
EventsListeners: 0
Registry: https://index.docker.io/v1/
Labels:
os=linux
region=eu-central-1
availability_zone=eu-central-1b
instance_type=t2.micro
node_type=manager
Experimental: true
Insecure Registries:
127.0.0.0/8
Live Restore Enabled: false