Docker build: read-only file system
Asked Answered
O

3

29

I'm using a Dockerfile to build my image and I have a command in there that says:

RUN sysctl -w net.ipv4.route.flush=1

but it fails to build the image with the following error:

Step 20 : RUN sysctl -w net.ipv4.route.flush=1
 ---> Running in 4d7302b56c53
sysctl: setting key "net.ipv4.route.flush": Read-only file system
Orthopedic answered 8/5, 2014 at 9:16 Comment(0)
J
18

For security reasons, you need to be in privileged mode for this operation. It is not currently possible to use a Dockerfile with the privileged mode.

$> docker run ubuntu sysctl -w net.ipv4.route.flush=1 && echo ok || echo ko
sysctl: setting key "net.ipv4.route.flush": Read-only file system
ko
$> docker run --privileged ubuntu sysctl -w net.ipv4.route.flush=1 && echo ok || echo ko
ok

Why do you need to do this at build time?

Janel answered 9/5, 2014 at 18:14 Comment(2)
This affect the host, so if you are doing it as buildtime, it won't be applied the the host running the actual container.Janel
I need it for mine to override Redis and add vm.overcommit_memory=1 to sysctl.conf or call sysctl -w vm.overcommit_memory=1 so fix a warning from redis to guard check saving when memory is low.Teyde
D
1

This may not apply to your exact situation, but I was receiving read-only file system notices frequently when trying to do a number of operations involving writes:

  • docker build
  • docker rmi
  • etc.

In my case, I was able to solve just by stopping and starting boot2docker:

$ bootdocker down
$ bootdocker up
Donation answered 27/5, 2015 at 20:39 Comment(0)
C
1

Late to the party, but I kept getting this error while running docker build. Turns out my machine just ran out of storage space! Rebooting and deleting all my temp files fixed it.

Coranto answered 18/12, 2022 at 21:50 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.