Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Docker build: read-only file system

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
like image 464
Romeo Mihalcea Avatar asked May 08 '14 09:05

Romeo Mihalcea


2 Answers

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?

like image 119
creack Avatar answered Oct 19 '22 23:10

creack


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
like image 23
Chris Peters Avatar answered Oct 20 '22 01:10

Chris Peters