我有一個linux卷,dev/sdh
,安裝在/media/ebs_volume
。當我嘗試使用-v /media/ebs_volume:/tmp/foo:ro
將其安裝到碼頭集裝箱中時,掛載的目錄/tmp/foo
爲空! ls -al /tmp/foo
從容器內部是空的,但主機上有ls -al /media/ebs_volume
有東西在裏面。Docker卷裝配顯示空目錄與Linux掛載目錄
[email protected] ~]$ ls -al /media/ebs_volume/
total 28
drwxr-xrwx 4 root root 4096 Jan 20 21:34 .
drwxr-xr-x 3 root root 4096 Jan 29 23:18 ..
drwx------ 2 root root 16384 Jan 20 21:29 lost+found
drwxrwxr-x 3 ec2-user ec2-user 4096 Jan 20 21:38 stuff
[[email protected] ~]$ docker run -it --rm -v /media/ebs_volume:/tmp/foo:ro nginx ls -al /tmp/foo
total 4
drwxr-xr-x 2 root root 4096 Jan 29 23:18 .
drwxrwxrwt 3 root root 16 Jan 30 17:33 ..
我試着在不同位置的主機上安裝卷,並從主機而不是整個目錄安裝一個特定的文件。如果我從主目錄安裝似乎沒有任何問題的東西。
任何人有任何想法可能發生在這裏或最好的方式來調試呢?
一些修改可能有用的輸出:
[[email protected] ~]$ mount
proc on /proc type proc (rw,relatime)
/dev/xvda1 on/type ext4 (rw,noatime,data=ordered)
/dev/xvdh on /media/ebs_volume type ext4 (rw,relatime,data=ordered)
...
[[email protected] ~]$ docker version
Client:
Version: 1.12.6
API version: 1.24
Go version: go1.6.3
Git commit: 7392c3b/1.12.6
Built: Fri Jan 6 22:16:21 2017
OS/Arch: linux/amd64
Server:
Version: 1.12.6
API version: 1.24
Go version: go1.6.3
Git commit: 7392c3b/1.12.6
Built: Fri Jan 6 22:16:21 2017
OS/Arch: linux/amd64
[[email protected] ~]$ cat /proc/version
Linux version 4.4.41-36.55.amzn1.x86_64 ([email protected]) (gcc version 4.8.3 20140911 (Red Hat 4.8.3-9) (GCC)) #1 SMP Wed Jan 18 01:03:26 UTC 2017
[[email protected] ~]$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
1436d3223b27 nginx "/bin/bash" 47 seconds ago Up 46 seconds 80/tcp, 443/tcp happy_leakey
[[email protected] ~]$ docker inspect 1436d3223b27
[
{
"Id": "1436d3223b270f78654d26682c469f4d7bdd24766c60f4052cb1a3fb60c86c12",
"Created": "2017-01-30T17:34:12.430135675Z",
"Path": "/bin/bash",
...
"Image": "sha256:cc1b614067128cd2f5cdafb258b0a4dd25760f14562bcce516c13f760c3b79c4",
...
"Driver": "devicemapper",
"MountLabel": "",
...
"HostConfig": {
"Binds": [
"/media/ebs_volume:/tmp/foo:ro"
],
"ContainerIDFile": "",
...
"VolumeDriver": "",
"VolumesFrom": null,
"CapAdd": null,
"CapDrop": null,
...
},
...
"Mounts": [
{
"Source": "/media/ebs_volume",
"Destination": "/tmp/foo",
"Mode": "ro",
"RW": false,
"Propagation": "rprivate"
}
],
"Config": {
...
"Env": [
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
"NGINX_VERSION=1.11.9-1~jessie"
],
"Cmd": [
"/bin/bash"
],
"Image": "nginx",
"Volumes": null,
...
},
...
}
]
你有沒有想出解決辦法?我遇到同樣的問題,它會掛載文件夾,但沒有文件! – Joel
抱歉@Joel。從來沒有找到一個真正乾淨的答案,但我已經提交了一個解決方案 解決方法。祝你好運 –