Skip to content

Commit 66836d8

Browse files
committed
/dev should not be readonly with --readonly flag
/dev is mounted on a tmpfs inside of a container. Processes inside of containers some times need to create devices nodes, or to setup a socket that listens on /dev/log Allowing these containers to run with the --readonly flag makes sense. Making a tmpfs readonly does not add any security to the container, since there is plenty of places where the container can write tmpfs content. I have no idea why /dev was excluded. Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
1 parent 6f58874 commit 66836d8

2 files changed

Lines changed: 2 additions & 2 deletions

File tree

daemon/oci_linux.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -541,7 +541,7 @@ func setMounts(daemon *Daemon, s *specs.Spec, c *container.Container, mounts []c
541541
if s.Root.Readonly {
542542
for i, m := range s.Mounts {
543543
switch m.Destination {
544-
case "/proc", "/dev/pts", "/dev/mqueue": // /dev is remounted by runc
544+
case "/proc", "/dev/pts", "/dev/mqueue", "/dev":
545545
continue
546546
}
547547
if _, ok := userMounts[m.Destination]; !ok {

integration-cli/docker_cli_run_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2874,7 +2874,7 @@ func (s *DockerSuite) TestRunContainerWithReadonlyRootfs(c *check.C) {
28742874
// Not applicable on Windows which does not support --read-only
28752875
testRequires(c, DaemonIsLinux)
28762876

2877-
testReadOnlyFile(c, "/file", "/etc/hosts", "/etc/resolv.conf", "/etc/hostname", "/sys/kernel", "/dev/.dont.touch.me")
2877+
testReadOnlyFile(c, "/file", "/etc/hosts", "/etc/resolv.conf", "/etc/hostname", "/sys/kernel")
28782878
}
28792879

28802880
func (s *DockerSuite) TestPermissionsPtsReadonlyRootfs(c *check.C) {

0 commit comments

Comments
 (0)