Jump to content

Attaching a docker container to multiple docker networks


Sivivatu

Recommended Posts

In my unraid environment i have multiple networks for internal and external applications. There are some containers that i want to have access to both of those networks (eg Authentik & Traefik)

Am I able to have a container appear in both networks?

In docker compose that would be an equilivant of:
 

```

networks:

  front:

    external: true

  back:

    external: true

 

services:

  application:

    image: example/image

    networks:

    - front

    - back

```

 

Cheers

Link to comment
  • 10 months later...

HI! Did you find any solution?

 

I have the same scenario as you, as I have Traefik and Authelia and different subnets and I want them to access both of those subnets.

 

I've tried:

docker network connect <bridge> <container-name>

without success. It creates another network interface (can see it via ifconfig) but creates it in the first place and traefik seems to stop working correctly.

 

Thanks in advance.

Link to comment
1 hour ago, adriaurora said:

 

 

I've tried:

docker network connect <bridge> <container-name>

without success. It creates another network interface (can see it via ifconfig) but creates it in the first place and traefik seems to stop working correctly.

 

Thats normal, apart from that, since you have been sparse with what "stop working correctly" is, i assume its connection broke, im gonna assume thats due to the changed default route. For some reason, docker has a wonky alphabetical-like order system. If you attach the network "bridge" it can cause it to take priority as default route, while something like the wgX interfaces might attach to it without that priority. You would have to fix that issue manually inside the container on starts up each time.

For anyone else interested into that, via dockerman you can add 
"&& docker network connect NETWORKNAME CONTAINERNAME" in post arguments

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.

×
×
  • Create New...