Adding command line options to Docker server start for custom default gateway


Recommended Posts

Hello,

 

I am trying to set docker (and all docker containers) to use a specific gateway on my network (Unraid uses dhcp gateway, 192.168.1.1, want containers to use a different, non dhcp gateway, same subnet though).

 

From the information I have found (https://docs.docker.com/v1.7/articles/networking/)it seems the way to do this is to start docker with the command line option "--default-gateway=IP_ADDRESS"

 

I edited /boot/config/docker.cfg and added:

DOCKER_OPTS="--default-gateway=192.168.1.254"

 

However, docker will not start when that it added, when I remove it docker starts as normal.

 

Does anyone know what I am doing wrong or if there is another way to achieve what I am doing that survives reboots and can be easily reverted if needed?

 

Would be great to be able to set the gateway only on specific containers but afaik there is no way to do that without multiple docker bridges and that seems a much more complicated solution, if it's even viable.

 

Link to comment
  • 1 month 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.