[英]Docker volume mounting shows empty directory with a linux mounted directory
I have a linux volume, dev/sdh
, that's mounted at /media/ebs_volume
. 我有一个linux卷,
dev/sdh
,它安装在/media/ebs_volume
。 When I try to mount it into a docker container using -v /media/ebs_volume:/tmp/foo:ro
, the mounted directory in /tmp/foo
is empty! 当我尝试使用,将其安装到一个码头工人容器
-v /media/ebs_volume:/tmp/foo:ro
,在安装目录下/tmp/foo
是空的! ls -al /tmp/foo
from inside the container is empty but ls -al /media/ebs_volume
on the host has stuff in it. 来自容器内部的
ls -al /tmp/foo
为空,但主机上的ls -al /media/ebs_volume
包含内容。
ec2-user@ip-10-0-2-50 ~]$ 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
[ec2-user@ip-10-0-2-50 ~]$ 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 ..
I've tried mounting the volume on the host in different locations, and mounting just a single specific file from the host instead of the entire directory. 我尝试在不同位置的主机上安装卷,并且只从主机而不是整个目录安装一个特定文件。 If I mount something from the home directory that seems to work without any issue.
如果我从主目录中挂载似乎没有任何问题的东西。
Anyone have any ideas what might be happening here or best way to debug this? 任何人都有任何想法可能会发生在这里或最好的调试方法?
Possibly useful output with some edits: 可能有用的输出有一些编辑:
[ec2-user@ip-10-0-2-50 ~]$ 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)
...
[ec2-user@ip-10-0-2-50 ~]$ 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
[ec2-user@ip-10-0-2-50 ~]$ cat /proc/version
Linux version 4.4.41-36.55.amzn1.x86_64 (mockbuild@gobi-build-60008) (gcc version 4.8.3 20140911 (Red Hat 4.8.3-9) (GCC) ) #1 SMP Wed Jan 18 01:03:26 UTC 2017
[ec2-user@ip-10-0-2-50 ~]$ 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
[ec2-user@ip-10-0-2-50 ~]$ 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,
...
},
...
}
]
Dirty solution, but I found that restarting the docker service via docker service restart
fixed this for me. 肮脏的解决方案,但我发现通过
docker service restart
为我修复了这个问题。
I was using ElasticBeanstalk for this and simply added some commands
to restart the service on deployment in my .config
file eg: 我正在使用ElasticBeanstalk,只是在我的
.config
文件中添加了一些commands
来重新启动部署服务,例如:
...
commands:
...
02-restart-docker:
command: service docker restart && docker restart ecs-agent
...
See http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/customize-containers-ec2.html and https://github.com/docker/docker/issues/5489#issuecomment-73427804 请参阅http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/customize-containers-ec2.html和https://github.com/docker/docker/issues/5489#issuecomment-73427804
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.