Reputation: 15571
Unfortunately, Docker does not persist the /etc/hosts file between RUN commands in Dockerfiles
Please recommend the best way to append to /etc/hosts within Dockerfile
Upvotes: 2
Views: 505
Reputation: 46470
It's best not to do this, mainly because you are tying the image to your network. Instead, use the --add-host
flag to docker run
to add entries e.g:
docker run --add-host test:127.0.0.1 nginx
Upvotes: 3