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.



















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