Skip to content

Commit d4afcbb

Browse files
feat(video): How I Run Docker on TrueNAS Like a Pro
1 parent c18048e commit d4afcbb

File tree

1 file changed

+132
-0
lines changed

1 file changed

+132
-0
lines changed

_posts/2025-07-11-truenas-docker-pro.md

Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ Then create the `compose.yaml` file
3434
nano compose.yaml
3535
```
3636

37+
### drawio `docker-compose.yml`
38+
3739
```yaml
3840
---
3941
services:
@@ -66,6 +68,8 @@ Then create the `compose.yaml` file
6668
nano compose.yaml
6769
```
6870

71+
### nginx `docker-compose.yml`
72+
6973
```yaml
7074
---
7175
services:
@@ -90,6 +94,8 @@ cd html
9094
nano index.html
9195
```
9296

97+
### nginx `index.html`
98+
9399
```html
94100
<!DOCTYPE html>
95101
<html lang="en">
@@ -130,6 +136,8 @@ Then create the `compose.yaml` file
130136
nano compose.yaml
131137
```
132138

139+
### code-server `docker-compose.yml`
140+
133141
```yaml
134142
---
135143
services:
@@ -163,10 +171,134 @@ PUID=950
163171
PGID=950
164172
TZ=America/Chicago
165173
```
174+
166175
---
167176

168177
Then add it to your `includes:` while creating a Custom App based on YAML.
169178

179+
## Bonus: Run Home Assistant with macvlan and Traefik on TrueNAS
180+
181+
If you’re self-hosting Home Assistant on TrueNAS, and you want:
182+
183+
- Native device discovery on your LAN (or VLAN!)
184+
- Reverse proxy access through your domain
185+
- A clean, Compose-managed setup
186+
187+
Then this combo of **Docker Compose + macvlan + Traefik** is exactly what you’re looking for.
188+
189+
> *Note: This setup is designed for users with a single NIC.* I have it connected to a bond in my homelab, which works fine, but I just want to keep it simple for this example. Also, you can host your Home Assistant on one network or VLAN while having your TrueNAS on another (that's how I do it).
190+
{: .prompt-info }
191+
192+
---
193+
194+
### Why macvlan?
195+
196+
By using `macvlan`, you give your Home Assistant container a **LAN IP**, just like a physical device. This enables:
197+
198+
- Proper device discovery (e.g., Google Home, Shelly, Zigbee)
199+
- Direct network communication with other LAN devices
200+
- Better compatibility with smart home protocols
201+
202+
---
203+
204+
### What You Need
205+
206+
Assumptions for this setup:
207+
208+
- Your NIC is `eth0`
209+
- Your LAN subnet is `192.168.20.0/24`
210+
- Your gateway is `192.168.20.1`
211+
- You want Home Assistant to have IP `192.168.20.202`
212+
- You're using **Traefik** as a reverse proxy (but optional)
213+
214+
---
215+
216+
### `docker-compose.yml`
217+
218+
```yaml
219+
services:
220+
homeassistant:
221+
container_name: homeassistant
222+
image: ghcr.io/home-assistant/home-assistant:stable
223+
pull_policy: always
224+
restart: unless-stopped
225+
env_file:
226+
- .env
227+
security_opt:
228+
- no-new-privileges:true
229+
networks:
230+
iot_macvlan:
231+
ipv4_address: 192.168.20.202
232+
traefik:
233+
volumes:
234+
- /etc/localtime:/etc/localtime:ro
235+
- /etc/timezone:/etc/timezone:ro
236+
- /mnt/storage0/home-assistant/config:/config
237+
labels:
238+
- "traefik.enable=true"
239+
- "traefik.http.routers.homeassistant.rule=Host(`homeassistant.yourdomain.com`)"
240+
- "traefik.http.routers.homeassistant.entrypoints=https"
241+
- "traefik.http.routers.homeassistant.tls=true"
242+
- "traefik.http.routers.homeassistant.tls.certresolver=cloudflare"
243+
- "traefik.http.services.homeassistant.loadbalancer.server.port=8123"
244+
245+
networks:
246+
iot_macvlan:
247+
external: true
248+
traefik:
249+
external: true
250+
```
251+
252+
> *Note: The `iot_macvlan` and `traefik` networks must already exist as external Docker networks. You can create the `macvlan` network using the command below.*
253+
{: .prompt-info }
254+
255+
---
256+
257+
### Create the macvlan Network
258+
259+
You only need to create the macvlan network once:
260+
261+
```bash
262+
docker network create -d macvlan \
263+
--subnet=192.168.20.0/24 \
264+
--gateway=192.168.20.1 \
265+
-o parent=eth0 \
266+
iot_macvlan
267+
```
268+
269+
> *Warning: macvlan works best with physical interfaces like `eth0`. It can work with bonded or VLAN interfaces too, but compatibility depends on your network setup and driver support.*
270+
{: .prompt-warning }
271+
272+
> *Danger: If you assign the same IP to more than one container or device, it will cause an IP conflict and could take your Home Assistant or host offline.*
273+
{: .prompt-danger }
274+
275+
---
276+
277+
### macvlan + Traefik
278+
279+
| Setting | Value | Description |
280+
|----------------------|-----------------------------------|---------------------------------------------------------|
281+
| **Interface** | `eth0` | Your physical NIC or bond that has access to tagged packets |
282+
| **Subnet** | `192.168.20.0/24` | Matches your LAN range |
283+
| **Gateway** | `192.168.20.1` | Gateway IP |
284+
| **Home Assistant IP** | `192.168.20.202` | LAN IP assigned to the container |
285+
| **Domain** | `homeassistant.yourdomain.com` | Used in your Traefik rule |
286+
| **Networks** | `iot_macvlan`, `traefik` | Must exist as external networks, created with the docker command |
287+
288+
---
289+
290+
### Results
291+
292+
With this setup:
293+
294+
- Home Assistant has a dedicated IP on your LAN
295+
- You can access it securely via Traefik + HTTPS
296+
- Everything is defined in Compose.
297+
298+
## Join the conversation
299+
300+
<blockquote class="twitter-tweet" data-dnt="true" data-theme="dark"><p lang="en" dir="ltr">&quot;Keep your data close… but your apps closer.&quot;<br>My new setup runs Docker apps on TrueNAS the clean way — using Compose, .env, and no hacks.<a href="https://t.co/RQ90braua3">https://t.co/RQ90braua3</a> <a href="https://t.co/NNvDO0zn0O">pic.twitter.com/NNvDO0zn0O</a></p>&mdash; Techno Tim (@TechnoTimLive) <a href="https://twitter.com/TechnoTimLive/status/1945145367072309294?ref_src=twsrc%5Etfw">July 15, 2025</a></blockquote> <script async src="https://platform.twitter.com/widgets.js" charset="utf-8"></script>
301+
170302
## Links
171303

172304
🛍️ Check out the new Merch Shop at <https://l.technotim.live/shop>

0 commit comments

Comments
 (0)