Reputation: 4974
I have a database on production (real os). And have docker-container with webserver and cgi (running on the same server).
And I cant get access to production database from container. How to open port (for example 3306) and make it visible in container? Thank you.
Upvotes: 0
Views: 432
Reputation: 5213
One of the ways is to pass the host machine's IP address to the container using the following approach:
docker run --add-host dockerhost:`/sbin/ip route|awk '/default/ { print $3}'` [my container]
This will add a host with the name dockerhost
to your container. You can then access the database running on the host via dockerhost:3306
Upvotes: 1