Docker for AWS中的节点找不到Docker根目录

时间:2018-06-13 07:25:10

标签: amazon-web-services docker docker-swarm diskspace docker-aws

我使用Docker for AWS创建了Docker群集群。在这个集群的每个节点中,我发现Docker root dir是/var/lib/docker,但是,我在文件系统中找不到这个目录。

docker info显示了这一点:

~ $ docker info
Containers: 7
 Running: 7
 Paused: 0
 Stopped: 0
Images: 9
Server Version: 17.06.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: k8nw4j8bt0mhip541vurvd785
 Is Manager: false
 Node Address: 10.x.y.z
 Manager Addresses:
  10.x.y.z:2377
  10.x.y.z:2377
  10.x.y.z:2377
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: cfb82a876ecc11b5ca0977d1733adbe58599088a
runc version: 2d41c047c83e09a6d61d464906feb2a2f3c52aa4
init version: 949e6fa
Security Options:
 seccomp
  Profile: default
Kernel Version: 4.9.36-moby
Operating System: Alpine Linux v3.5
OSType: linux
Architecture: x86_64
CPUs: 2
Total Memory: 7.293GiB
Name: ip-10-x-y-z.us-west-2.compute.internal
ID: 4YZB:UYHX:REW2:ENBZ:AAEW:BS6T:HB5B:OQCE:FRBU:DPXX:SJWV:GRGL
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): true
 File Descriptors: 163
 Goroutines: 233
 System Time: 2018-06-13T07:04:01.824290758Z
 EventsListeners: 5
Registry: https://index.docker.io/v1/
Labels:
 os=linux
 region=us-west-2
 availability_zone=us-west-2a
 instance_type=m3.large
 node_type=worker
Experimental: true
Insecure Registries:
 127.0.0.0/8
Live Restore Enabled: false

它清楚地显示Docker Root Dir/var/lib/docker,但是,当我使用ls时,它说无法找到目录:

~ $ sudo ls /var/lib/docker
ls: /var/lib/docker: No such file or directory

~ $ sudo ls -al /var/lib/
total 20
drwxr-xr-x    5 root     root          4096 Jun 25  2017 .
drwxr-xr-x    1 root     root          4096 Jun 27  2017 ..
drwxr-xr-x    2 root     root          4096 Jun 25  2017 apk
drwxr-xr-x    2 root     root          4096 Jun 25  2017 misc
drwxr-xr-x    2 root     root          4096 Jun 25  2017 udhcpd

关于Docker的磁盘使用情况,Docker使用的磁盘数量超过2.3GB

/ $ docker system df
TYPE                TOTAL               ACTIVE              SIZE                RECLAIMABLE
Images              9                   6                   2.361GB             1.702GB (72%)
Containers          7                   7                   665.1kB             0B (0%)
Local Volumes       6                   6                   19.85MB             0B (0%)

关于文件系统使用情况,df命令显示使用了2.9GB空间,这是预期的,因为Docker单独消耗超过2.3GB。

/ $ sudo df -h
Filesystem                Size      Used Available Use% Mounted on
overlay                  19.7G      2.9G     15.8G  15% /
tmpfs                     3.6G         0      3.6G   0% /dev
tmpfs                     3.6G         0      3.6G   0% /sys/fs/cgroup
tmpfs                     3.6G    161.2M      3.5G   4% /etc/group
tmpfs                     3.6G    161.2M      3.5G   4% /etc/passwd
tmpfs                     3.6G    161.2M      3.5G   4% /etc/shadow
/dev/xvdb1               19.7G      2.9G     15.8G  15% /etc/ssh
tmpfs                     3.6G    161.2M      3.5G   4% /home/docker
/dev/xvdb1               19.7G      2.9G     15.8G  15% /var/log
/dev/xvdb1               19.7G      2.9G     15.8G  15% /etc/resolv.conf
/dev/xvdb1               19.7G      2.9G     15.8G  15% /etc/hostname
/dev/xvdb1               19.7G      2.9G     15.8G  15% /etc/hosts
shm                      64.0M         0     64.0M   0% /dev/shm
tmpfs                   746.8M    916.0K    745.9M   0% /var/run/docker.sock
tmpfs                     3.6G    161.2M      3.5G   4% /usr/bin/docker
tmpfs                     3.6G         0      3.6G   0% /proc/kcore
tmpfs                     3.6G         0      3.6G   0% /proc/timer_list
tmpfs                     3.6G         0      3.6G   0% /proc/sched_debug
tmpfs                     3.6G         0      3.6G   0% /sys/firmware

同时,关于磁盘使用情况:

/ $ sudo du -h -d 1
0   ./sys
31.5M   ./usr
1.8M    ./etc
0   ./proc
12.0K   ./home
216.0K  ./sbin
4.0K    ./tmp
8.0K    ./run
4.0K    ./root
1.4M    ./bin
114.3M  ./var
4.0K    ./mnt
16.0K   ./media
2.8M    ./lib
0   ./dev
4.0K    ./srv
152.2M  .

du报告仅使用了152.2M磁盘,/var文件夹仅使用了114.3M,似乎du无法找到/ var / lib / docker,和Docker以某种方式存储其数据(2.3 + GB)du无法找到。

如果我使用docker inspect检查此节点上正在运行的某个容器,则会显示/var/lib/docker下的多个文件夹。

任何人都可以了解原因吗?感谢。

1 个答案:

答案 0 :(得分:4)

这是因为与docker用户(https://docs.docker.com/docker-for-aws/faqs/#what-are-the-editions-containers-running-after-deployment)一起SSH时,aws的docker使用shell容器,因此您实际上无权访问根目录所在的主机。

您可以通过特权容器访问主机,方法是先与docker用户sshing,然后运行类似命令:| | | | 1 | | | | | |_________________| 2 | | | | | | | | 3 | | | | |