Search code examples
dockernetwork-programminginterface

Start container with multiple interfaces, one that routes to another docker image and another that uses bridge


I'm trying to connect a docker image to another docker image while still retaining internet connection.

However, when I run

 docker run --net=bridge --net=ethereum-net -d -p 8080:8080 fe3a31e5d94d

I get

docker: conflicting options: cannot attach both user-defined and non-user-defined network-modes.

Solution

  • By default, docker networks will utilize a bridge network driver when being created.

    In that case --net=bridge is not required when you run the containers.

    Assuming Ethereum-net was created as a default bridge network, using --net=ethereum-net when running both containers will ensure both containers can communicate together, and they should still have external internet access. You can inspect the docker network to check the driver used to be sure.

    If the containers on the network cannot communicate externally and the network is a bridge network, then you should inspect the subnet used for the bridge network to verify it does not overlap with your external network subnet. If there's an overlap, it won't route traffic correctly.