Docker Community Forums

Share and learn in the Docker community.

Aliasing or adding host.docker.local via --add-host


(Benjamincribb) #1

I want to define a custom domain name to the IP address represented by host.docker.local in the /etc/hosts in my container, which as I understand is defined as the docker container boots up.

I have an app running on my host which I need my docker container to communicate with, but I won’t know what the container thinks is the IP of my host until the container is up, and I’m not allowed to edit /etc/hosts any more.

I don’t really want to edit the docker container if possible. I’d prefer to either make a quick change to the instance while running, or possibly add the address during execution of the docker run command.

Is it possible to know the host.docker.local IP before runtime?
Is it possible to pass this address in --add-host?
if not, is it possible to edit /etc/hosts after the instance is running?