containers / podman-compose

a script to run docker-compose.yml using podman
GNU General Public License v2.0
4.88k stars 470 forks source link

How can I configure the bridge network to be accessible from other machines? #865

Open Sheng2216 opened 4 months ago

Sheng2216 commented 4 months ago

Hello everyone, I am new to podman-compose. I need to host a service called Zigbee2MQTT on my Debian host machine. However, I am having trouble accessing the web UI of the service from another machine on the same local area network(I can access from the host machine only). How can I address this issue? I have learned that by using sudo (which I need to access the Zigbee dongle attached to my host machine), a bridge network is created. However, this bridge network is isolated, and no one except the host machine can access it.

I also tried adding network_mode=host to the .yml file, but I received an error message stating that I cannot use multiple networks. Error: cannot set multiple networks without bridge network mode, selected mode host: invalid argument I apologize if this seems like a dumb question. Any help would be greatly appreciated!

Here is my docker-compose.yml file:

services:
  mqtt:
    container_name: mosquitto
    image: eclipse-mosquitto:2.0
    restart: unless-stopped
    volumes:
      - "./mosquitto-data:/mosquitto"
    ports:
      - "1883:1883"
      - "9001:9001"
    command: "mosquitto -c /mosquitto-no-auth.conf"
    #network_mode: host

  zigbee2mqtt:
    container_name: zigbee2mqtt
    restart: unless-stopped
    image: koenkk/zigbee2mqtt:1.32.2
    volumes:
      - ./zigbee2mqtt-data:/app/data
      - /run/udev:/run/udev:ro
    ports:
      - "8080:8080"
    environment:
      - TZ=Asian/Hong_Kong
    devices:
      - /dev/ttyUSB6:/dev/ttyUSB6
    #network_mode: host
Sheng2216 commented 4 months ago

I noticed that when running Podman in a clean environment without Docker installed, it functions as expected. However, if Docker is pre-installed, it causes conflicts and only Docker works properly.