Docker Community Forums

Share and learn in the Docker community.

Trying to figure out how to create a docker image with 2 network interfaces, and have the open port available from outside

Here’s the deal. I have a machine running docker server

It has eth0 (we’ll call it and eth1 (we’ll call it

I create two networks
docker network create --subnet= --gateway= eth0
docker network create --subnet= --gateway= eth1

Then I create my container
docker create -it --net eth0 --name test <image}

Then I attach the 2nd network
docker network connect eth1 test

My docker compose has a single command that runs on on udp port 3480. This is where I can’t figure out how to invoke my container, as everything gives me an error.

What’s the command I use here?
If I use docker start test, it doesn’t work.
If I use docker run, I can’t refer to it by name, so it also doesn’t work, as it uses the default networks.

I’m stuck here and don’t know what to do.

FYI, if I use only a single network, I can start it up via
docker run -itd -p :port:port/udp --network=eth1 --name test

and it works fine. I just either need to now how to attach multiple networks in the run command, or how to use my existing container with docker run.

OK, I have this 90% figured out. I can use all the same arguments with docker create, then add the 2nd network with docker network connect, then use docker start. Now I just have to figure out how to assign the 2nd network’s IP address.