Skip to main content Getting error when using network_mode:container? : r/docker
r/docker icon
Go to docker

Getting error when using network_mode:container?

I have a vpn client container that seems to be working properly, it connects to the server and all that. I am trying to use it as my network for other containers but I am getting this error whenever I try to create the new containers:

"ERROR: for [container]  Cannot create container for service [container]: conflicting options: host and and the network mode"

I am stumped because I originally had this working at one point. The first time I tried making this container all the other ones were able to connect to it successfully, but I had to recreate it trying to fix an unrelated issue and, without changing anything, this error showed up.

I have tried making new containers under different names and completely remaking the docker-compose and conf files, but it doesn't seem like anything is fixing the issue. I am unable to find a solution that works anywhere online.

Any help would be greatly appreciated, I don't know what else to try at this point, thank you!

Edit: adding compose files

vpn container:

version: "2.1"
services:
  mullvad:
    image: linuxserver/wireguard
    container_name: mullvad
    hostname: mullvad
    cap_add:
      - NET_ADMIN
      - SYS_MODULE
    environment:
      - PUID=1000
      - PGID=1000
      - TZ=$TZ
    volumes:
      - ./config:/config
      - /lib/modules:/lib/modules
    ports:
      - 51820:51820/udp
    sysctls:
      - net.ipv6.conf.all.disable_ipv6=0
      - net.ipv4.conf.all.src_valid_mark=1
    restart: always

networks:
  default:
    external:
      name: vpn

example container:

version: "2.1"
services:
  qbittorrent:
    image: linuxserver/qbittorrent
    container_name: qbittorrent
    hostname: qbittorrent
    network_mode: container:$VPN_CONTAINER
    environment:
      - PUID=1000
      - PGID=1000
      - TZ=$TZ
      - UMASK_SET=022
      - WEBUI_PORT=8080
    volumes:
      - ./config:/config
      - ./downloads:/downloads
    ports:
      - 6881:6881
      - 6881:6881/udp
      - 8080:8080
    restart: unless-stopped
Global Threat Intelligence Report H2 2024
Thumbnail image: Global Threat Intelligence Report H2 2024
Sort by:
Best
Open comment sort options
[deleted]

Comment deleted by user

Edited post with the compose files

More replies

Did you pass host networking flag by mistake?

I dont think so, i edited the post with compose files

More replies

So you made a Docker network that is using the bridge driver and called it vpn? And that’s the network the vpn container is running on? And you’re trying to create another container that will use the vpn container as it’s network? When you made the vpn network did you enable “manually attachable”? You could move the mulvad container back to the stock Docker bridge network and try the qbitorrent container creation again to test. See if the Docker network you’re using is the problem.

You are correct about all your assumptions, although I did not enable "manually attachable." I have tried not making an external network and just having the container use the default one it creates, is that what you are suggesting to try?

More replies
More replies

Are your environment variables as they should be? Maybe they got messed up.

I believe so, they are almost identical to the template off dockerhub.

More replies

Remove the hostname option from qbittorrent. Ports as well

Was this fixed?