Portainer Network Mode/Host Error

Hi all,

I am new to Docker and Portainer and I am having an issue with my Gluetun stack (Gluetun, NATMAP, Jackett, qBittorrent), I can get it setup and running but if I try to use the Recreate button inside Portainer to rebuild the container I get the following error message.

“Failed recreating container: Create container error: Error response from daemon: conflicting options: hostname and the network mode”

I am lost as to why I get this error as everything in the stack works correctly, the vpn connection and network pass-through all work, the only issue is recreating the container, note that I am creating the stack using Docker Compose, if I try to do it from inside Portainer it throws the above error message but the stack is still created correctly. I have tried removing the hostname from the compose file, and setting one specifically (vpn), I get the same result.

Anyone else had this issue, any advise?

Here is my compose file.

services:
  gluetun:
    image: qmcgaw/gluetun
    container_name: gluetun
    # line above must be uncommented to allow external containers to connect.
    # See https://github.com/qdm12/gluetun-wiki/blob/main/setup/connect-a-container-to-gluetun.md#external-container-to-gluetun
    cap_add:
      - NET_ADMIN
    devices:
      - /dev/net/tun:/dev/net/tun
    ports:
      - 9117:9117 # Jackett
      - 8080:8080 # qBittorrent
      - 8888:8888/tcp # HTTP proxy
      - 8388:8388/tcp # Shadowsocks
      - 8388:8388/udp # Shadowsocks
    volumes:
      - /home/uhax/Docker/Gluetun:/gluetun
    environment:
      # See https://github.com/qdm12/gluetun-wiki/tree/main/setup#setup
      - VPN_SERVICE_PROVIDER=protonvpn
      # - VPN_TYPE=wireguard
      # OpenVPN:
      - OPENVPN_USER=
      - OPENVPN_PASSWORD=
      - SERVER_COUNTRIES=New Zealand
      - PORT_FORWARD_ONLY=on
      # Wireguard:
      # - WIREGUARD_PRIVATE_KEY=
      # - WIREGUARD_ADDRESSES=
      # Timezone for accurate log times
      - TZ=Pacific/Auckland
      # Server list updater
      # See https://github.com/qdm12/gluetun-wiki/blob/main/setup/servers.md#update-the-vpn-servers-list
      - UPDATER_PERIOD=24h
      - PORT_FORWARD_ONLY=on
      # - VPN_PORT_FORWARDING_PROVIDER=protonvpn
    restart: unless-stopped
  qbittorrent:
    image: lscr.io/linuxserver/qbittorrent:latest
    container_name: qbittorrent
    environment:
      - PUID=1000
      - PGID=1000
      - TZ=Pacific/Auckland
    volumes:
      - /home/uhax/Docker/qBittorrent/appdata:/config
      - /home/uhax/Torrents:/downloads #optional
      - /home/uhax/Downloads:/blackhole #optional
    restart: unless-stopped
    network_mode: "service:gluetun"
    depends_on:
      gluetun:
        condition: service_healthy
  qbittorrent-natmap:
    # https://github.com/soxfor/qbittorrent-natmap
    image: ghcr.io/soxfor/qbittorrent-natmap:latest
    container_name: qbittorrent-natmap
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock:ro
    environment:
      - TZ=Pacific/Auckland
      - QBITTORRENT_SERVER=localhost
      - QBITTORRENT_PORT=8080
      - QBITTORRENT_USER=
      - QBITTORRENT_PASS=
      # - VPN_GATEWAY=
      # - VPN_CT_NAME=gluetun
      # - VPN_IF_NAME=tun0
      # - CHECK_INTERVAL=300
      # - NAT_LEASE_LIFETIME=300
    restart: unless-stopped
    network_mode: "service:gluetun"
    depends_on:
      gluetun:
        condition: service_healthy
  jackett:
    image: lscr.io/linuxserver/jackett:latest
    container_name: jackett
    environment:
      - PUID=1000
      - PGID=1000
      - TZ=Pacific/Auckland
      - AUTO_UPDATE=true #optional
    volumes:
      - /home/uhax/Docker/Jackett/data:/config
      - /home/uhax/Docker/Jackett/blackhole:/downloads
    restart: unless-stopped
    network_mode: "service:gluetun"
    depends_on:
      gluetun:
        condition: service_healthy

Which one?

If it is about recreating then you have a container which works, and the new container cannot be created.

Stack indicates you run Swarm stacks, but you also menation compose. Which one you use?

The error message says the hostname option and the network mode is conflicting, which is true, since you can’t set the hostname when when you use the network namespace of another container or the host network. Using another network namespace means you also use the hostname of the other container.

Since there is no hostname in your compose file, I have no idea what the problem is. If it is a Portainer bug, you can try a portainer forum

https://docs.portainer.io/#getting-support

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.