meallhour
meallhour

Reputation: 15571

What is the best way to append to /etc/hosts within Dockerfile

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

Answers (1)

Adrian Mouat
Adrian Mouat

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

Related Questions