1

I have two machines: machine-A and machine-B. Both are on different networks. I create a docker container on machine-A using docker-compose.yml and run litecoind process within it on port 12345. I have forwarded port 12345 to the port 80 of the host machine-A.

version: '3'
services:
  node1:
    build: .
    cap_add:
      - ALL
    command: litecoind -regtest -server -rpcuser=rpc -rpcpassword=x -rpcport=10340  --datadir=/root/litecoind-simnet/ -port=12345
    networks:
      vpcbr:
        ipv4_address: 10.9.0.11
    ports:
      - 80:12345
networks:
  vpcbr:
    driver: bridge
    ipam:
     config:
       - subnet: 10.9.0.0/16

Now on machine-B, I can directly connect to the above process with -addnode option of litecoin and can see the blockchains syncing.

Problem arises when I create a container on machine-B and try to connect to the same above process with -addnode by using the docker-compose.yml file on machine-B. In this case, the litecoind process remains invisible and the blockchains do not sync.

version: '3'
services:
  node1:
    build: .
    cap_add:
      - ALL
    command: litecoind -regtest -addnode=<x.x.x.x:80> -rpcuser=rpc -rpcpassword=x -rpcport=10340  --datadir=/root/litecoind-simnet/ -port=12345
    networks:
      vpcbr:
        ipv4_address: 10.8.0.11
    ports:
      - 90:12345
networks:
  vpcbr:
    driver: bridge
    ipam:
     config:
       - subnet: 10.8.0.0/16

I want the above two separate containers on two separate remote machines to communicate with each other. What am I missing? Help please. Thanks.

1 Answers1

0

The possible solutions are

  1. Use a single docker-compose file to deploy both the containers on same node.

  2. If your requirement is to absolutely deploy the containers on two different nodes then you need to create a swarm cluster if you are using compose.

  3. If you want to create two different compose file on same node this is the answered here

asolanki
  • 1,333
  • 11
  • 18
  • Thanks for your reply. I want to absolutely deploy the containers on two different remote machines as I am trying to simulate a real-life situation of any node adding and dropping from the p2p network. With swarm mode, as per my understanding we have to use the "overlay" network option which I have tried and is working fine, but I want to see if its possible with a bridge network option of docker networking. So, is it possible without using swarm? – Bajarang Sutar May 24 '19 at 11:17