2

I use docker to unpack a linux chroot and then execute commands into it, but I get this inside the chroot.

echo ciao > /dev/null
bash: /dev/null: Permission denied

I thought that the null device must be corrupted so I tried something else:

rm -f /dev/null ; mknod -m 0666 /dev/null c 1 3; echo ciao > /dev/null 
bash: /dev/null: Permission denied

But it also did not work.

Doing stat on the main /dev/null and the one inside the chroot showed no difference at all.

I am writing this because it seems I was the first person in the writing about this problem.

LtWorf
  • 141
  • 1
  • 7

1 Answers1

2

My chroot is being extracted on a tmpfs, for speed reasons, which I mount passing --tmpfs /tmpfs:exec to docker.

My mount was this:

tmpfs on /tmpfs type tmpfs (rw,nosuid,nodev,relatime)`

Turns out that, similarly to how I have to pass exec to override the default noexec that docker adds to tmpfs mounts, there is a nodev passed that I have to override.

So the parameter becomes this:

--tmpfs /tmpfs:exec,dev

The annoying part is that mknod does not fail or report any error. The device file is created but it won't work.

LtWorf
  • 141
  • 1
  • 7