简体   繁体   中英

Connectivity from microservice on host out of docker-compose network

I have a docker-compose.yml with several spring cloud microservices executing on my local machine. But I want an microservice executing on the local machain, not in a docker. This microservice can access to de external docker ip but can't access to the internal ips that "eureka" has registred. I try (Unsuccessfully) deploy an OpenVPN docker. ¿What is the better solution to work with only one microservice in develop out of the docker network?

Unfortunately, docker-compose is a tool that can be used with a docker only. If you just need to run and manage microservice app you can search for some other solutions like supervisor etc.

But if I correctly understood your case then you have local machine (with IP for example 192.168.100.1) and a running microservice in docker (with it's own docker network IP like 172.17.0.2). On the local machine, you have also running another service that listens for example port 1234. And you need access service that listens 192.168.100.1:1234 from within docker container that has internal IP 172.17.0.2. In that case you just need to start your microservice in docker and use port exposing ( https://docs.docker.com/compose/compose-file/#ports ). In that case, you can run your docker container, expose port 1234 for example to the same port 1234 on the host and that's all. All traffic between 192.168.100.1:1234 and 172.17.0.2:1234 will be transparently passed so from inside your running container you can use target IP of docker (often it's 172.17.0.1, you can check actual value by running ifconfig on your local machine and check network interface docker0) and port 1234

docker0   Link encap:Ethernet  HWaddr 02:42:B1:B5:7B:53
          inet addr:172.17.0.1  Bcast:0.0.0.0  Mask:255.255.0.0

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM