Connect to local macOS/Windows localhost (127.0.0.1) from within Docker Container Image


Docker access host localhost within container

If you have created a docker image, say a Ubuntu base image with Apache Tomcat and you want to access Oracle/MySQL that has been installed on your local macOS/Windows system and you are wondering how to connect your device localhost from within the Docker container, then do the below,

Solution:

Make use of host.docker.internal instead of using localhost or 127.0.0.1



Note: Works are using Docker v18.03 and above.







Author Info:

Rakesh (He/Him) has a Masters Degree in Computer Science with over 15+ years of experience in Web and Application development. He is the author of insightful How-To articles for Code2care.

Follow him on: X

You can also reach out to him via e-mail: rakesh@code2care.org

Copyright © Code2care 2024 | Privacy Policy | About Us | Contact Us | Sitemap