Complete Answer
- Prepare your own
hosts
file you wish to add to docker container;
1.2.3.4 abc.tv
5.6.7.8 domain.xyz
1.3.5.7 odd.org
2.4.6.8 even.net
- COPY your
hosts
file into the container by adding the following line in the Dockerfile
COPY hosts /etc/hosts_extra
- If you know how to use
ENTRYPOINT
or CMD
or CRON
job then incorporate the following command line into it or at least run this inside the running container:
cat /etc/hosts_extra >> etc/hosts;
- You cannot add the following in the
Dockerfile
because the modification will be lost:
RUN cat /etc/hosts_extra >> etc/hosts;