Adding a static ip to just one docker


gvtci
Go to solution Solved by sphbecker,

Recommended Posts

Hi Jorge;

 

Thank You for answering my question, but now another question arises. I've 20 dockers that I want to run do I need to burn a live ip address for each docker? I would like to use the same ip address but with different port numbers. Please advise.

 

Thank You again.

Link to comment
  • Solution
18 hours ago, gvtci said:

Hi Jorge;

 

Thank You for answering my question, but now another question arises. I've 20 dockers that I want to run do I need to burn a live ip address for each docker? I would like to use the same ip address but with different port numbers. Please advise.

 

Thank You again.

 

 

Your best bet for a GUI configuration is to use the Bridge network, which creates an internal subnet for your dockers and allows port mapping from the UNRAID server's IP address to specific dockers. It works great, the only downside is sharing the server's native IP might lead to port number conflicts. You can work around that by using non-standard port numbers, such as 8443 instead of 443, but that can get annoying.

 

If you don't mind dipping into the command line, you can create your own custom docker network using the bridge driver, which will work the same as above, but allows you to bind the docker network with a different local IP address; meaning your dockers could use a different LAN IP address than your server, which sounds like what you are looking for.

Link to comment
4 hours ago, gvtci said:

Thank You for your help guys. I am just going to configure them with command line.

 

This is what I did.

 

Run a command like this to give Unraid a 2nd IP address on the default br0 interface.

ip addr add 192.168.1.22/24 dev br0

That will only last until your next reboot, so add the command to the /boot/config/go script to rerun on each reboot; it should be above the command to start emhttp.

 

At that point you have two choices, you can edit your docker container and instead of providing only a port number like 443, you can provide IP and port in this format 192.168.1.22:443. Now that docker will use the new IP address instead of Unraid's IP address. That is probably the easiest way to do it.

 

If you have a lot of dockers working together for a specific purpose, you might want to create a custom docker network that binds to the 2nd IP address. That can be done with this command. Note, that command is permanent, no need to add to the go script.

docker network create -o "com.docker.network.bridge.host_binding_ipv4"="192.168.1.22" my-docker-network

At that point, any docker container you assign to my-docker-network will use the IP provided with any ports you specify.

 

Important note: there is a bug/limitation in Unraid's docker GUI. The port mapping information shown on the status screen will incorrectly show the ports mapped to the server's IP address, however, they should work correctly using the custom IP address, this is only a display bug.

Edited by sphbecker
  • Thanks 1
Link to comment
  • 4 months later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.