How to run HomeAssistant on Docker, on its own network instead of the host network?

Tags: #<Tag:0x00007f326ba2bb98> #<Tag:0x00007f326ba2b8f0>

I have an issue where I cannot run the emulated hue bridge because port 80 is already used by my Synology. I was told I can create a “network” to run my container on, but I just dont understand the process to do it.

Anyone done this before and can point me in the right direction?

I don’t think you need “network”

Docker run -p 8123:8123…

That will change HA from running “host” vs you publishing individuals ports.

This however will not change hue issue. I cannot remember but I don’t think emulated hue work unless using host and external devices not discovering emulated hue but I may e wrong. Haven’t used that integration in a while

Anyway docker documation explains ports and networking

Homeassistant works fine, it only is the emulated hue issue I am trying to resolve.

You can create a macvlan so that the homassistant container will get it’s own IP adress and you can use all ports on that

But will not be able to communicate with devices on the main network?

If you generate a MACVLAN and assign a unique address to your container, it will become a standalone device on your network.
It can also communicate with other devices on the network without any problems.
But be careful: It can no longer communicate with the Docker Host, because the host network and possible MACVLANS or other Docker networks are decoupled.
For this you have to set up a loopback an tell your host machine how to cummincate with your macvlan containers.

This is a confoguration example for docker macvlan with host connection how I did it:

 docker network create -d macvlan -o parent=eno1 \
   --subnet \
   --gateway \
   --ip-range \
   --aux-address 'host=' \

 ip link add mynet-shim link eno1 type macvlan  mode bridge

 ip addr add dev mynet-shim
 ip link set mynet-shim up

 ip route add dev mynet-shim

The first command generates a Docker MACVLAN with the reserved IP address, so that it is not used by Docker when creating containers.

The second command generates a MACVLAN interface named mynet-shim on the Docker host

The third and fourth commands assign the host MACVLAN interface the previously reserved IP address and start it

The fifth command tells the host how to use that interface when communicating with the containers

Thank you, can you clarify which should be my new network IP for homeassistant, and which would be the loopback for my main network?

These where only the commands with which you can create your docker network and tell your host how to communicate with your macvlan containers.
You can then set the IP address of your Homassistant Container for example in your docker-compose.yaml.

For me looks like this:

    external: true
    external: true

    container_name: home-assistant
    image: homeassistant/home-assistant
      driver: "fluentd"
        tag: docker.homeassistant
      - "timescale"
      - "esphome"
      - "mqtt"
      - "reverse-proxy"
      - "deconz"
    restart: always
      - /srv/dev-disk-by-id-ata-ST32000542AS_5XW2HFG7/data/docker_data/homeassistant:/config
      - /etc/localtime:/etc/localtime:ro
      - /dev/serial/by-id/:/dev/serial/by-id
    privileged: true
      - "traefik.enable=true"
      - "traefik.http.routers.http-catchall.rule=hostregexp(`{host:.+}`)"
      - "traefik.http.routers.http-catchall.entrypoints=web"
      - "t[email protected]docker"
      - "traefik.http.middlewares.redirect-to-https.redirectscheme.scheme=https"
      - "traefik.http.routers.homeassistant.rule=Host(``)"
      - "traefik.http.routers.homeassistant.entrypoints=websecure"
      - "traefik.http.routers.homeassistant.tls.certresolver=mytlschallenge"
      - ""
      - ""
      - "8123:8123"

I have assigned two networks to my Homassistant Container. The previously created MACVLAN and a proxy network for Traefik. You can ignore the proxy network and all the labels part, if you don’t use it.
The Homassistant ip in this example is

1 Like

You can simply take my commands and adapt them for your network.
What is your gateway address (your router)?

For example, if your gateway address is, you have to adapt my first command like this:

 docker network create -d macvlan -o parent=NAME_OF_YOUR_HOST_NETWORKCARD \
   --subnet \
   --gateway \
   --ip-range \
   --aux-address 'host=' \

Then change the rest accordingly

Be aware that Synology native packages such as VPN-server and Surveillance-Stations not play well with network interfaces created outside of Synology’s Docker UI.

I’ve been in contact with support trying to understand what parts that are missing when using the CLI but they just say that we must use the GUI (i.e. I don’t get past 1-2nd line support).

1 Like

Have you heard any more on this? When you say don’t play nicely, when using VPN, is it not able to see the IP used from macvlan for HA? I am new to HA (first week) and have started to implement a lot. I planned on using VPN to access from remote rather than the cloud service.

I’ll go search the Synology forums, but while on the topic of port 80 in DSM, anyone know why its forwarded to the port you choose in DSM setup? Perhaps break this forward. Would solve OP.

##Update. Read up on the need for port 80 on synology. Would require a hack to alter. Use macvlan.



If you dont need the 32 IP block for the HA network, I presume the following would work?

docker network create -d macvlan -o parent=eno1 --subnet= --gateway= --ip-range= mynet

Hello all

Sorry for the post digging up but I have a similar problem than I’m not able to solve. I hope @CM000n could help me :wink:

I have a server (OMV) on which run Docker and Portainer. This server have only one physical network interface (enp7s0)

I have also an Unifi network with different Vlans (CORE, IOT, SEC) and the server OMV is installed on the CORE Vlan.

I would like to install HA on Docker with an access to the different Vlans by using MacVlan but I have not sufficient competences to do that. I would create different virtual interfaces with specific MACaddress and specific IPV4 (One per Vlan)

Any help would be much apreciate

Thanks in advance,