Docker shared network stack (e.g. docker run --network='container:<name|ID>')


Recommended Posts

Docker has some functionality where multiple containers can share the same network namespace by using --network='container:<name|id>'. Here's the relevant documentation from the docker run network settings docs:

--network="bridge" : Connect a container to a network
                      'bridge': create a network stack on the default Docker bridge
                      'none': no networking
                      'container:<name|id>': reuse another container's network stack
                      'host': use the Docker host network stack
                      '<network-name>|<network-id>': connect to a user-defined network

I implemented this without a problem in prior versions of Unraid by setting the Docker "Network Type" in the Unraid template to "None", then setting the "Extra Parameters" to "--network='container:NAME'". This would yield a docker run command that had both the "--network='none'" and "--network='container:NAME'" parameters.

 

This worked great until I updated to Unraid 6.8. It looks the new version of docker no longer allows you to overload the "--network='none'" parameter with the "--network='container:NAME'" parameter and throws this error:

/usr/bin/docker: Error response from daemon: Container cannot be connected to network endpoints: container:NAME, none.
See '/usr/bin/docker run --help'.

So, I've got two questions to try and sort this out:

  1. Is there a way in the Unraid template to not send a "--network" parameter? If so, I could just take care of that in the "Extra Parameters". If not, it would be great to add the functionality.
  2. Is there a way in the Unraid template to set the network to "container:NAME"? I tried to edit the underlying XML, but it doesn't look like the templating engine is picking up changes. If this is not an option, it would be great to add the functionality


I appreciate any help. Thanks!

Link to comment
13 hours ago, burkasaurusrex said:

Docker has some functionality where multiple containers can share the same network namespace by using --network='container:<name|id>'. Here's the relevant documentation from the docker run network settings docs:


--network="bridge" : Connect a container to a network
                      'bridge': create a network stack on the default Docker bridge
                      'none': no networking
                      'container:<name|id>': reuse another container's network stack
                      'host': use the Docker host network stack
                      '<network-name>|<network-id>': connect to a user-defined network

I implemented this without a problem in prior versions of Unraid by setting the Docker "Network Type" in the Unraid template to "None", then setting the "Extra Parameters" to "--network='container:NAME'". This would yield a docker run command that had both the "--network='none'" and "--network='container:NAME'" parameters.

 

This worked great until I updated to Unraid 6.8. It looks the new version of docker no longer allows you to overload the "--network='none'" parameter with the "--network='container:NAME'" parameter and throws this error:


/usr/bin/docker: Error response from daemon: Container cannot be connected to network endpoints: container:NAME, none.
See '/usr/bin/docker run --help'.

So, I've got two questions to try and sort this out:

  1. Is there a way in the Unraid template to not send a "--network" parameter? If so, I could just take care of that in the "Extra Parameters". If not, it would be great to add the functionality.
  2. Is there a way in the Unraid template to set the network to "container:NAME"? I tried to edit the underlying XML, but it doesn't look like the templating engine is picking up changes. If this is not an option, it would be great to add the functionality


I appreciate any help. Thanks!

Someone on reddit told me to create a network with the name of your container, look at this https://www.reddit.com/r/unRAID/comments/ebgt06/have_you_guys_noticed_any_quirks_or_bugs_in_68/fb9fr1t/?st=k4bal2a9&sh=3b483579

  • Thanks 1
Link to comment
7 hours ago, jedduff said:

Someone on reddit told me to create a network with the name of your container, look at this https://www.reddit.com/r/unRAID/comments/ebgt06/have_you_guys_noticed_any_quirks_or_bugs_in_68/fb9fr1t/?st=k4bal2a9&sh=3b483579

Awesome - this worked perfectly for me. Thanks @jedduff!

 

For posterity, open terminal and run:

docker network create container:NAME

Then change "Network" to "CUSTOM:conatiner:NAME" in all of the Unraid Docker templates.

 

Probably worth changing the Unraid setting to preserve customer network names as well.

Link to comment

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.