How can I pass the hosts saved in /etc/hosts
into the docker image while building it.
I want to do this automatically, so that this snippet works on all server environments.
I tried this in the Dockerfile:
COPY /etc/hosts /etc/hosts
But obviously that didnt work with the following error:
COPY failed: stat /var/lib/docker/tmp/docker-builder736360024/etc/hosts: no such file or directory
I also tried to move the hosts
(cp /etc/hosts /app/dir
) first in my app-folder and then copying only with in the Dockerfile:
COPY hosts /etc/hosts
That didn't throw an error, but looking in a docker container, the container hosts are not the same as the hosting machine.
I also tried to build the image with the additional --add-host
parameter, but that also did not work.
How can I do this correctly?