hyprstack
hyprstack

Reputation: 4229

Write to /etc/hosts in docker container when running docker container

I am trying to write to the file in /etc/hosts within a docker container when I perform the run command, but when I shh into the container and check the hosts file, nothing has been written.

What is the correct command to do this?

I am running my image with the following command:

docker run -it -p 3000:3000 <imageName> bash echo 192.168.56.101 mypath.dev >> /etc/hosts

Upvotes: 2

Views: 943

Answers (1)

Mark O&#39;Connor
Mark O&#39;Connor

Reputation: 78011

Use the "add-host" parameter when running the container:

docker run -it --add-host db-static:86.75.30.9 ubuntu cat /etc/hosts

Upvotes: 4

Related Questions