docker / cli

The Docker CLI
Apache License 2.0
4.95k stars 1.93k forks source link

Enhancement: implement --mount type=device #742

Open Nemo157 opened 6 years ago

Nemo157 commented 6 years ago

Description

Cannot pass a : character as part of a device name when starting a container.

Steps to reproduce the issue:

  1. Have a device node containing a : character
  2. Attempt to run a docker container with this device mounted into it.

Describe the results you received:

> sudo ln -s random /dev/example:device
> docker run --device /dev/example:device alpine sh -c 'head -c 5 /dev/example:device | base64'
invalid argument "/dev/example:device" for --device: device is not an absolute path

Describe the results you expected:

Some way to escape the : character to successfully mount this device.

Output of docker version:

Docker version 17.10.0-ce, build f4ffd2511c
thaJeztah commented 6 years ago

Yes, the --device (like --volume) option uses colons as a separator between options, and uses the --device <device on host>:<path-in-container>[:<options>] format

To resolve this, we'd probably need an additional syntax, similar to what's used for the --mount option (or would it make sense to add a type=device option to --mount? @cpuguy83 ?).

cpuguy83 commented 6 years ago

--mount would be a good fit for this.

thaJeztah commented 5 years ago

Changed the title to reflect the proposed change to facilitate this 👍

0x0elliot commented 1 year ago

seems like this is fixed as well. shouldn't this be closed?

thaJeztah commented 1 year ago

I don't think type=device has been implemented in the API; https://github.com/moby/moby/blob/8bb58153e75b4310f3ae9ec6d03924aa286fbf20/api/types/mount/mount.go#L7

// Type represents the type of a mount.
type Type string

// Type constants
const (
    // TypeBind is the type for mounting host dir
    TypeBind Type = "bind"
    // TypeVolume is the type for remote storage volumes
    TypeVolume Type = "volume"
    // TypeTmpfs is the type for mounting tmpfs
    TypeTmpfs Type = "tmpfs"
    // TypeNamedPipe is the type for mounting Windows named pipes
    TypeNamedPipe Type = "npipe"
    // TypeCluster is the type for Swarm Cluster Volumes.
    TypeCluster Type = "cluster"
)