0

I am using Docker version 20.10.7 and building below mentioned docker file:

FROM maven:3.6.3-adoptopenjdk-11

COPY ./ ./

RUN addgroup --gid 900--system gtest
RUN adduser --uid 9000--system --disabled-password --gecos "" --shell /bin/sh --ingroup gtest utest;

RUN chmod 777 /etc/hosts 

USER 9000

ENTRYPOINT ["./start.sh"]

Docker builds throws:

#13 0.368 chmod: changing permissions of '/etc/hosts': Read-only file system

In start.sh i need to update /etc/hosts as user utest(9000). Is it possible to change permissions of /etc/hosts (make it writeable) in docker file or is it forbidden in docker ?

user10916892
  • 825
  • 12
  • 33
  • Pleas check [this](https://stackoverflow.com/questions/38302867/how-to-update-etc-hosts-file-in-docker-image-during-docker-build) and [this](https://stackoverflow.com/questions/69310515/docker-when-does-etc-hosts-gets-created-or-updated-inside-container) answers. – Rony Sep 25 '21 at 10:14
  • (It'd be better to try to avoid using `/etc/hosts` at all; it's a confusing source of errors if a host name means different things on different machines and manually keeping the file in sync in multiple places is a hassle.) – David Maze Sep 25 '21 at 11:19

0 Answers0