Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Consul share network from docker

There is consul server in docker.

  vote-consul-server:
    image: consul:1.7.2
    environment:
      CONSUL_BIND_INTERFACE: eth0
    ports:
      - "${CONSUL_PORT}:8500"

It generates hosts for registred applications. The main problem is that anothers applications can't communicate between each other if they are not in docker.

For example: I have config-service (docker with consul), user-service(IDE). When user-service starts, it asks for configurations from config-server, but consul gives not correct link (available only in docker network).

c.c.c.ConfigServicePropertySourceLocator : Fetching config from server at : http://83a6c7ab12d0:8888/

How to publish all links from consul(docker)?

like image 653
yazabara Avatar asked Jun 04 '26 16:06

yazabara


1 Answers

Since every container has own IP and may have own network, you can try to use host networking:

docker run --rm -d --network host --name vote-consul-server

For more details, see host networking tutorial.

Also, you can learn about networking from the container’s point of view

like image 54
Yasen Avatar answered Jun 07 '26 11:06

Yasen



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!