mirror of
https://github.com/docker/cli.git
synced 2026-09-25 17:02:07 -04:00
Add --device flag to allow additional host devices in container
We add a --device flag which can be used like: docker run --device /dev/sda:/dev/xvda:rwm ubuntu /bin/bash To allow the container to have read write permissions to access the host's /dev/sda via a node named /dev/xvda in the container. Note: Much of this code was written by Dinesh Subhraveti dineshs@altiscale.com (github: dineshs-altiscale) and so he deserves a ton of credit. Docker-DCO-1.1-Signed-off-by: Timothy <timothyhobbs@seznam.cz> (github: timthelion) Upstream-commit: e855c4b92170534864b920ec1e267b3a815764f9 Component: engine
This commit is contained in:
@@ -919,6 +919,22 @@ func TestRunUnprivilegedWithChroot(t *testing.T) {
|
||||
logDone("run - unprivileged with chroot")
|
||||
}
|
||||
|
||||
func TestAddingOptionalDevices(t *testing.T) {
|
||||
cmd := exec.Command(dockerBinary, "run", "--device", "/dev/zero:/dev/nulo", "busybox", "sh", "-c", "ls /dev/nulo")
|
||||
|
||||
out, _, err := runCommandWithOutput(cmd)
|
||||
if err != nil {
|
||||
t.Fatal(err, out)
|
||||
}
|
||||
|
||||
if actual := strings.Trim(out, "\r\n"); actual != "/dev/nulo" {
|
||||
t.Fatalf("expected output /dev/nulo, received %s", actual)
|
||||
}
|
||||
deleteAllContainers()
|
||||
|
||||
logDone("run - test --device argument")
|
||||
}
|
||||
|
||||
func TestModeHostname(t *testing.T) {
|
||||
cmd := exec.Command(dockerBinary, "run", "-h=testhostname", "busybox", "cat", "/etc/hostname")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user