I understand that it's possible to expose host to container manually, using the docker bridge network. But how can I make life easier to accomplish the linking by using the --link switch?

For example, I want to connect the database running on the host system from a container. One way to do it is to manually set the connection destination of the app in the container to the IP address of the host on the docker bridge network (docker0 by default). Many docker images however provides an easy way to just use --link to connect to a database. How can I accomplish it in this case?


Docker links are exclusively for container-to-container communication.

To expose ports elsewhere, you'll need to use -P or -p.

  • I actually meant the reverse way: expose host to container. – xuhdev Feb 26 '15 at 21:56
  • Same deal. Links won't help you here. – EEAA Feb 26 '15 at 21:57
  • Possibility to expose host to container discussed here: github.com/docker/docker/issues/1143 – Anatoliy Dec 8 '15 at 21:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.