
Version : '3.4' services : nginx : build : nginx In this example we are going to call our network pi which can be created with the command: To get around this you need to create an external network. However, if you have other docker containers running in another docker-compose file it won’t be able to communicate with these containers. This allows each of the containers to communicate with each other using the service name (e.g. When you run docker-compose up it automatically creates an internal network for all of your docker containers in that file. I set up docker-compose files for everything I run on my Raspberry Pi, as these can be checked in to git. I tend to use Hypriot for all of my Raspberry Pis as it saves setting up docker manually each time. I am going to assume you already have a Raspberry Pi set up and able to run docker images. I am going to go through the steps needed to set up both and the pros and cons of each. However, recently I have switched to Traefik and I have found it is much easier to maintain. Up until recently, I have been using nginx as a reverse proxy for my docker containers. Refer to traefik’s docs for a list of available matchers.I use my Raspberry Pi as my own personal home server. Url = " If all went well you should be able to access home assistant at Tweak the rule in dynamic_conf.toml to your preferred forwarding setting. dynamic_conf.toml:/etc/traefik/dynamic_conf.tomlįilename = "/etc/traefik/dynamic_conf.toml" # So that Traefik can listen to the Docker events # This network is not required for home-assistant but for other docker containers

Home assistant still uses network_mode: host and runs on port 8123 but traefik accesses it by its local IP address. Most of the replies in this thread are about traefik v1.x, here is my config for v2.1 in case anyone finds it useful. Not sure I have explained this entirely well.

The /28 gives me 16 usable addresses on the LAN for containers, I could increase this with a /27 or event a /26. I might try and simplify this by running every container in the mtacvlan network. I have got around this by using the traffic_proxy network to hook the hass front end into traefik, using the default network to allow the hass containers including db (not shown), influxdb (not shown) etc… to talk to each other. The big challenge with mtacvlan is that the container cannot talk to the host on the mtacvlan network. var/run/docker.sock:/var/run/docker.sock ".users=yyyyyy:$$xxxxxxxxxxxxxxxxxxxxx" CLOUDFLARE_API_KEY=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

It creates me a /28 network range I can use for docker containers on my local network:ĭocker network create -d macvlan -subnet=192.168.1.0/24 -ip-range=192.168.1.16/28 -gateway=192.168.1.1 -o parent=ens33 macvlan Here is the mtacvlan setup from my ubuntu docker host.
Here is one of the other containers: node-red: Image: 'homeassistant/home-assistant:latest' I’ll try and break it down: version: "3.6" Note, I’m using a DNS challenge for LetsEncrypt, you should probably replace that for a HTTP challenge, unless there’s a reason for you to use a DNS challenge. # note: wild cards like the one below only work with DNS challenge # watch Docker, when new containers are created with label create mapping. My traefik.toml looks like this: debug = false You can probably figure out how your docker-compose.yml would look like, by looking at my Ansible config though: - name: "Create Home Assistant container" I use Ansible instead of docker-compose, which is fairly similar in terms of syntax (both YAML), but not the same.
