Docker Community Forums

Share and learn in the Docker community.

How to build the docker image with customized IP in /etc/hosts file


(Rameshvs) #1

Hi Team,

Is there any way to build the docker image with customized IP in /etc/hosts file ?

I can see --add-host option in docker container run command to add custom IP in existing docker image. But if I use this option I need to start the container with customized IP all time.

Thanks,
Ramesh


(Roel Van De Paar) #2

We now have a single-line workaround here


(Romain Beuque) #3

In my case, I need to have a specific /etc/hosts file during the build, so I think it could be great if it was added :slight_smile:


(Dimplerohara) #4

Is this command adding the host entry to the container’s /etc/hosts file? I can not see that happening. If I bash inside container, and ping the host i just added, it is still not resolvable inside it. Please let me know if I am missing anything.