Docker Community Forums

Share and learn in the Docker community.

Why can not build the Dockerfile with chmod /etc/hosts?

I used a WSL2 with Docker-desktop.
I type a command as follows:

$ docker build -t fromtest:0.0 .

The Dockerfile is simple

FROM ubuntu:latest
RUN chmod 644 /etc/hosts

Then, the error message is

chmod:changing permission of ‘/etc/hosts’ : Read-only file system.

In Virtual Box, however, the build oeration with same Dockerfile is successful.
So I think this problem only appears in WSL.

What should I do to succeed in build?