There were two related questions but they didn't quite answer the question. But if mods think this is a duplicate, please let me know.
I have a docker-compose.yml file that deploys phpmyadmin. There is a mysql server hosted locally on the host proper (NOT as a container).
I have a config file for phpmyadmin to connect to my database. I can't seem to find a domain name for docker host so I've been taking the subnet that the containers deploy on and using the .1
of the subnet. For example, initially containers deployed to 172.16.0.0/24 and so I declared in phpmyadmin's configuration to connect to 172.16.0.1
This question was born out of the fact that every time I re-deployed, i.e. issued docker-compose down && docker-compose up -d
the network address kept changing. My work around is to explicitly declare the default ipam network subnet, which is a fine workaround and actually preferred because I can then pin mysql user logins to the ip address range.
But given that docker knows to resolve the container service "phpmyadmin" to the container's IP address, I figured there MUST be something for the host so I wouldn't have to re-declare the IP address each time.
So, is there a "hostname" that a container can use to talk to the host or am I stuck using IP addresses?
Edit: I'm using docker on Linux and would very much prefer to not run the container in host mode.