You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: _posts/2025-07-11-truenas-docker-pro.md
+132Lines changed: 132 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -34,6 +34,8 @@ Then create the `compose.yaml` file
34
34
nano compose.yaml
35
35
```
36
36
37
+
### drawio `docker-compose.yml`
38
+
37
39
```yaml
38
40
---
39
41
services:
@@ -66,6 +68,8 @@ Then create the `compose.yaml` file
66
68
nano compose.yaml
67
69
```
68
70
71
+
### nginx `docker-compose.yml`
72
+
69
73
```yaml
70
74
---
71
75
services:
@@ -90,6 +94,8 @@ cd html
90
94
nano index.html
91
95
```
92
96
97
+
### nginx `index.html`
98
+
93
99
```html
94
100
<!DOCTYPE html>
95
101
<html lang="en">
@@ -130,6 +136,8 @@ Then create the `compose.yaml` file
130
136
nano compose.yaml
131
137
```
132
138
139
+
### code-server `docker-compose.yml`
140
+
133
141
```yaml
134
142
---
135
143
services:
@@ -163,10 +171,134 @@ PUID=950
163
171
PGID=950
164
172
TZ=America/Chicago
165
173
```
174
+
166
175
---
167
176
168
177
Then add it to your `includes:` while creating a Custom App based on YAML.
169
178
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)
> *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.*
| **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">"Keep your data close… but your apps closer."<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>— 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
+
170
302
## Links
171
303
172
304
🛍️ Check out the new Merch Shop at <https://l.technotim.live/shop>
0 commit comments