Skip to content

Follow symlink for --device argument #13840

@GeertJohan

Description

@GeertJohan

A --device argument fails when the listed device is actually a symlink to a device.

Example:
docker run --device /dev/disk/by-id/virtio-52525e7b-fe7b-4889-8:/dev/somevolume …etc…
Fails with an error.
Cannot start container 7edf77076ea5ea42b098728092c45bef24c9a742f3f122abf3b3bfd6bbaf2ef2: error gathering device information while adding custom device "/dev/disk/by-id/virtio-52525e7b-fe7b-4889-8": not a device node

The /dev/disk/by-id entry is ofcourse a symlink to the actual device.
$ ls -al /dev/disk/by-id/virtio-52525e7b-fe7b-4889-8 lrwxrwxrwx 1 root root 9 Jun 10 09:52 /dev/disk/by-id/virtio-52525e7b-fe7b-4889-8 -> ../../vdc

The problem here is that I have no clue what the actual device path is when writing the docker run command in the service unit-file. It would be nice if docker could handle a device symlink, right now I have to manually resolve it to the correct device path.

There was an issue about this (#13706), but it was closed for a different reason.

uname -a
Linux redactedhostname.novalocal 4.0.3 #2 SMP Thu May 14 00:34:07 UTC 2015 x86_64 Intel Xeon E312xx (Sandy Bridge) GenuineIntel GNU/Linux

docker version

Client version: 1.6.2
Client API version: 1.18
Go version (client): go1.4.2
Git commit (client): 7c8fca2-dirty
OS/Arch (client): linux/amd64
Server version: 1.6.2
Server API version: 1.18
Go version (server): go1.4.2
Git commit (server): 7c8fca2-dirty
OS/Arch (server): linux/amd64

docker -D info

Containers: 1
Images: 9
Storage Driver: btrfs
 Build Version: Btrfs v3.17.1
 Library Version: 101
Execution Driver: native-0.2
Kernel Version: 4.0.3
Operating System: CoreOS 681.0.0
CPUs: 8
Total Memory: 15.68 GiB
Name: redactedhostname.novalocal
ID: S5RN:M3TJ:MSQ5:PMUC:QSET:5EMW:3FVJ:KHDR:RPBD:PHDG:JV3L:WCGV
Debug mode (server): false
Debug mode (client): true
Fds: 10
Goroutines: 19
System Time: Wed Jun 10 10:00:33 UTC 2015
EventsListeners: 0
Init SHA1: 75be3e87b0c63694ce2c69ab3f2c4251d6f69f83
Init Path: /usr/libexec/docker/dockerinit
Docker Root Dir: /var/lib/docker

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions