Try setup compose to install HA docker on Qnap NAS with Static IP Address

Tried to modify a successful compose file of Home Assistant on Qnap server by setup bridge, static IP address. But I got error “ipv4_address is not allowed” Anyone can help me correct the code?

version: '3'
services:
  homeassistant:
    container_name: homeassistant
    image: "ghcr.io/home-assistant/home-assistant:latest"
    volumes:
      - /share/CACHEDEV1_DATA/Container/HAconfig:/config
      - /etc/localtime:/etc/localtime:ro
    restart: unless-stopped
    privileged: true
    network_mode: bridge
    ip4_address: 192.168.18.238

The orginial compose file uses network_mode: host with no ip4_address. That was good.

I don’t think you can use this ip address as ip address in a bridge mode is defined in docker. This is very likely why you are getting this error. I use it with host mode and it is working fine. If you remove ip address it should work.
Any reason you must use bridge mode?

1 Like

When I do manual setup, I found out using bridge mode with static ip works great. However, looks like it is easier to use host mode. Just worry about security since my NAS ip will be exposed to external (when I use outside of my home). However, After testing a few applications. I found out. host mode works. bridge mode without setup ip works. all I need to do is edit docker and manual change IP address to my existing one. it works as well. your listed chatgpt recommanded script returns with warning and set docker not in bridge mode. I can change it to bridge mode as well.

If you use a host mode than ip address will be mapped to your host ip, as I know.
In bridge mode you will need a reverse proxy to access it. There are some differences but you can check docker networking for details.
If you run

sudo netstat -plnt

you can see difference between host and bridge mode containers.

At moment, I can config compose.yaml file to setup network as bridge. Then, after docker created. Manually change network IP to it was.