Assigning Docker containers to specific physical port

Hi All,

I’m wanting to assign a node to a different physical port on my system as I have 4 of them. I’ve seen that people use Pipework to do this but I was wondering if anyone has seen a native way within Docker to do do this. Any feedback would be greatly appreciated.

I think what nerdatwork linked should cover the question, but I had explored more regarding the Docker ports here:

Thanks for the suggestions!

just to clarify, what people have responded with is specific or multiple containers running on different ports, for port forwarding purposes, yes? not separate IPs, like for example I have an Odroid H2+ running two separate nodes on two different ports. Although, the Odroid H2+ has two physical ethernet ports, which are both 2.5 gbps. I only have one connected to my switch, which the switch port is only 1 gbps. Although, this isn’t much of an issue as traffic trends have never warranted needing more bandwidth.

If someone wanted to connect multiple RJ45 ports (in my case 2, but as it sounds like the OP mentions 4 ports) and then specify which IP/port each node’s traffic is going through, is there a simple way to do that?

In my personal situation, although the switch’s ports are limited to 1 gbps, it does have two 10 gbps SPF+ uplink ports, which are aggregated to a core switch, so the switch itself has 20 gbps uplink…but then again, my WAN connection is limited to 1 gbps…so the point is very moot.

I do get what the responses were but it’s not exactly what I’m trying to do. Matter of fact, it’s not really even related to StorJ. I’m trying to isolate at the hardware level which actual hardware port is used. I know I can designate IP addresses and such for the container but need to pass a containers traffic to different hardware port which is why I referenced the Pipework link. With the wealth of knowledge this forum brings to the table I thought I’d ask around to see if anyone has done this before and if docker is capable. The guy that wrote the Pipework stuff said to be sure and check to see if the latest docker improvements included a way but I wasn’t seeing it.

And I should add to that, I would like to pass the Storj containers to a NIC that has a VPN attached to it and then another container to a separate ETH port for local LAN use and getting it away from the VPN for internet as well.

To bind to the specific interface, you can specify its IP in the -p option, like -p

If you would use a --network host, all -p will stop to work and this container will not be in the isolated network, it will be in the same network as a host. And then you need something like iptables to route the traffic. You still can bind to a different interface, but not in the docker container, you should do that in the server.address: of the config.yaml file instead.

1 Like