N
N
nepster-web2017-04-03 12:30:17
Docker
nepster-web, 2017-04-03 12:30:17

How to make two docker friends?

There are two docker assemblies (not 2 containers, but two full-fledged separate assemblies, each of which has its own containers).
Suppose one assembly is an API, and the second is a Client.
Each of them has its own internal network:

...
networks:
    travelnet:
        driver: bridge
        ipam:
            config:
                - subnet: 172.27.0.0/24
...

In another docker assembly (Client), everything is exactly the same, only IP: 192.168.100.0/24
Accordingly, ports are forwarded to my local machine, everything works, the internal network between images inside each assembly also works.
However, the problem is that I cannot access the container of one assembly to the container of another assembly.
For example, in the assembly of the API in the alpine container, I do
ping 192.168.100.17nothing
and vice versa from the Client in the alpine container I do
ping 172.27.0.0.100- and so the ping does not go.
Could you tell me, please, how to establish such a contact?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
O
Oleg Kolzhanov, 2017-04-04
@clockworkbird

I have not used it myself yet, but as far as I know, it is done through external-network:
In the service of the first assembly, from which you need a connection to the network from another assembly, you prescribe the corresponding networkone from the second assembly, and in the second assembly of the network to which you connect, you prescribe the parameter: external: true
For example:

# first/docker-compose.yml
version: '2'
services:
  first:
    ...
    networks:
      - network1
networks:
  network1:
    driver: bridge
...

# second/docker-compose.yml
version: '2'
services:
  second:
    ...
    networks:
      - first_network1
networks:
  first_network1:
    external: true

After that, you can access from one service to another - from firstdoping second

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question