profile
viewpoint

Ask questionsNew devices on host are not exposed to privileged container

I have a very simple container, basically gliderlabs/alpine:3.2 with python running on a machine in AWS.

Inside that container, I have a script that attaches an EBS volume to the instance and then mounts it. To run the container I am using:

docker run --privileged -v /mnt:/mnt

I then run the script. It attaches the EBS volume to /dev/xvdc, but when it goes to mount the volume, /dev/xvdc isn't there.

subprocess.CalledProcessError: Command '['mount', '/dev/xvdc', '/mnt/nsqd-1']' returned non-zero exit status 255
bash-4.3# mount /dev/xvdc /mnt/nsqd-1
mount: mounting /dev/xvdc on /mnt/nsqd-1 failed: No such file or directory
bash-4.3# ls /mnt
nsqd-1

Outside the container, the device exists:

core@ip-172-31-8-49 ~ $ ls /dev/xvdc
/dev/xvdc

If a new device is exposed in /dev, I would expect to see it exposed to a running privileged container also.

core@ip-172-31-8-49 ~ $ docker version
Client version: 1.7.1
Client API version: 1.19
Go version (client): go1.4.2
Git commit (client): 2c2c52b-dirty
OS/Arch (client): linux/amd64
Server version: 1.7.1
Server API version: 1.19
Go version (server): go1.4.2
Git commit (server): 2c2c52b-dirty
OS/Arch (server): linux/amd64

core@ip-172-31-8-49 ~ $ docker info
Containers: 13
Images: 125
Storage Driver: overlay
 Backing Filesystem: extfs
Execution Driver: native-0.2
Logging Driver: json-file
Kernel Version: 4.1.6-coreos-r1
Operating System: CoreOS 766.3.0
CPUs: 1
Total Memory: 3.679 GiB
Name: ip-172-31-8-49.us-west-1.compute.internal
ID: WLDJ:3VZB:AARA:BILE:TLZK:ALOX:V7OY:UZB3:HPS6:QY3J:5ZIE:4XNA

core@ip-172-31-8-49 ~ $ uname -a
Linux ip-172-31-8-49.us-west-1.compute.internal 4.1.6-coreos-r1 #2 SMP Wed Sep 2 04:16:15 UTC 2015 x86_64 Intel(R) Xeon(R) CPU E5-2670 v2 @ 2.50GHz GenuineIntel GNU/Linux
moby/moby

Answer questions DuBistKomisch

/dev:/dev as a volume worked well enough for me

useful!

Related questions

Swarm restarts all containers hot 2
can not successfully install docker-ce on ubuntu 16.04 ? why ,Can you help me? hot 1
OCI runtime exec failed: exec failed: cannot exec a container that has stopped: unknown hot 1
Allow COPY command's --chown to be dynamically populated via ENV or ARG hot 1
windowsRS1 and windowsRS5-process are failing due to "Unable to delete '\gopath\src\github.com\docker\docker" hot 1
Panic: runtime error: invalid memory address or nil pointer dereference hot 1
Error response from daemon: rpc error: code = DeadlineExceeded desc = context deadline exceeded hot 1
one container in the overlay network not available hot 1
Containers on overlay network cannot reach other containers hot 1
[Windows] windowsfilter folder impossible to delete hot 1
swarm node lost leader status hot 1
New-SmbGlobalMapping don't continued working in Container hot 1
failed to export image: failed to create image: failed to get layer: layer does not exist hot 1
"docker stack deploy">"rpc error: code = 3 desc = name must be valid as a DNS name component" hot 1
runc regression - EPERM running containers from selinux hot 1
Github User Rank List