|
| 1 | +--- |
| 2 | +layout: post |
| 3 | +title: "How I Run Docker on TrueNAS Like a Pro" |
| 4 | +date: 2025-07-14 08:00:00 -0500 |
| 5 | +categories: self-hosted |
| 6 | +tags: homelab truenas self-hosted docker |
| 7 | +image: |
| 8 | + path: /assets/img/headers/truenas-docker-pro-hero.webp |
| 9 | + lqip: data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2wCEAAEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAf/AABEIAAUACgMBEQACEQEDEQH/xAGiAAABBQEBAQEBAQAAAAAAAAAAAQIDBAUGBwgJCgsQAAIBAwMCBAMFBQQEAAABfQECAwAEEQUSITFBBhNRYQcicRQygZGhCCNCscEVUtHwJDNicoIJChYXGBkaJSYnKCkqNDU2Nzg5OkNERUZHSElKU1RVVldYWVpjZGVmZ2hpanN0dXZ3eHl6g4SFhoeIiYqSk5SVlpeYmZqio6Slpqeoqaqys7S1tre4ubrCw8TFxsfIycrS09TV1tfY2drh4uPk5ebn6Onq8fLz9PX29/j5+gEAAwEBAQEBAQEBAQAAAAAAAAECAwQFBgcICQoLEQACAQIEBAMEBwUEBAABAncAAQIDEQQFITEGEkFRB2FxEyIygQgUQpGhscEJIzNS8BVictEKFiQ04SXxFxgZGiYnKCkqNTY3ODk6Q0RFRkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1dnd4eXqCg4SFhoeIiYqSk5SVlpeYmZqio6Slpqeoqaqys7S1tre4ubrCw8TFxsfIycrS09TV1tfY2dri4+Tl5ufo6ery8/T19vf4+fr/2gAMAwEAAhEDEQA/AP4uvCv7Tup/Dnw1/wAIfZeBvDWpQmLVLK81a5utXtdT1C2vpblLqG8+wXUFlcRlJUjgE1pI8UVtbwM8sH2mK55cXgqOMn7SrXzWLbjJU6GfZ3hMPBwSgvZ4TCY+hhqSnGEXVVOlFV5r2lZTnqGHqyoyqclHA30hKpPLsDVr1IrmklVxFahUrVORzl7Lnm3SjKUabim0epeG/wBmDwvr3h3QNcfxL4ktn1nRdK1Z7dTYSrA2o2MF40IlNqhkERmKCQohcLuKqTgdvtH5fj/mRyLz/D/I/wD/2Q== |
| 10 | +--- |
| 11 | + |
| 12 | +Learn how to run Docker apps on TrueNAS like a pro — with full control, clean YAML, and no extra dashboards. |
| 13 | + |
| 14 | +Have questions or a different setup that works for you? Leave a comment, I'd love to hear how others are running Docker on TrueNAS. |
| 15 | + |
| 16 | +{% include embed/youtube.html id='gPL7_tzsJO8' %} |
| 17 | +📺 [Watch Video](https://www.youtube.com/watch?v=gPL7_tzsJO8) |
| 18 | + |
| 19 | +## The Approach |
| 20 | + |
| 21 | +We're going to: |
| 22 | + |
| 23 | +- Create a dataset to store our containers and configs |
| 24 | +- Use Docker Compose and `.env` files |
| 25 | +- Optionally manage everything from a browser using Code Server |
| 26 | + |
| 27 | +## Example 1: Basic Stateless Container (Draw.io) |
| 28 | + |
| 29 | +First make the dataset `drawio` in the TrueNAS UI. |
| 30 | + |
| 31 | +Then create the `compose.yaml` file |
| 32 | + |
| 33 | +```shell |
| 34 | +nano compose.yaml |
| 35 | +``` |
| 36 | + |
| 37 | +```yaml |
| 38 | +--- |
| 39 | +services: |
| 40 | + drawio: |
| 41 | + image: jgraph/drawio |
| 42 | + container_name: drawio |
| 43 | + restart: unless-stopped |
| 44 | + ports: |
| 45 | + - 9080:8080 |
| 46 | + - 9443:8443 |
| 47 | + environment: |
| 48 | + - PUBLIC_DNS=${PUBLIC_DNS:-domain} |
| 49 | + healthcheck: |
| 50 | + test: ["CMD-SHELL", "curl -f http://localhost:8080 || exit 1"] |
| 51 | + interval: 5s |
| 52 | + timeout: 5s |
| 53 | + retries: 5 |
| 54 | + start_period: 10s |
| 55 | +``` |
| 56 | +
|
| 57 | +Then add it to your `includes:` while creating a Custom App based on YAML. |
| 58 | + |
| 59 | +## Example 2: NGINX with Volume Mounts |
| 60 | + |
| 61 | +First make the dataset `nginx` in the TrueNAS UI. |
| 62 | + |
| 63 | +Then create the `compose.yaml` file |
| 64 | + |
| 65 | +```shell |
| 66 | +nano compose.yaml |
| 67 | +``` |
| 68 | + |
| 69 | +```yaml |
| 70 | +--- |
| 71 | +services: |
| 72 | + nginx: |
| 73 | + image: nginx:1-alpine |
| 74 | + ports: |
| 75 | + - 8099:80 |
| 76 | + volumes: |
| 77 | + - ./html/:/usr/share/nginx/html |
| 78 | +``` |
| 79 | + |
| 80 | +Create the html folder |
| 81 | + |
| 82 | +```shell |
| 83 | +mkdir html |
| 84 | +``` |
| 85 | + |
| 86 | +inside of there create an `index.html` file |
| 87 | + |
| 88 | +```shell |
| 89 | +cd html |
| 90 | +nano index.html |
| 91 | +``` |
| 92 | + |
| 93 | +```html |
| 94 | +<!DOCTYPE html> |
| 95 | +<html lang="en"> |
| 96 | +<head> |
| 97 | + <meta charset="UTF-8"> |
| 98 | + <title>Hello World App</title> |
| 99 | + <meta name="viewport" content="width=device-width, initial-scale=1.0"> |
| 100 | + <style> |
| 101 | + body { |
| 102 | + font-family: sans-serif; |
| 103 | + display: flex; |
| 104 | + height: 100vh; |
| 105 | + justify-content: center; |
| 106 | + align-items: center; |
| 107 | + background-color: #f0f0f0; |
| 108 | + margin: 0; |
| 109 | + } |
| 110 | + h1 { |
| 111 | + color: #333; |
| 112 | + } |
| 113 | + </style> |
| 114 | +</head> |
| 115 | +<body> |
| 116 | + <h1>Hello, World!</h1> |
| 117 | +</body> |
| 118 | +</html> |
| 119 | +``` |
| 120 | + |
| 121 | +Then add it to your `includes:` while creating a Custom App based on YAML. |
| 122 | + |
| 123 | +## Example 3: Code Server for Web-Based Editing |
| 124 | + |
| 125 | +First make the dataset `code-server` in the TrueNAS UI. |
| 126 | + |
| 127 | +Then create the `compose.yaml` file |
| 128 | + |
| 129 | +```shell |
| 130 | +nano compose.yaml |
| 131 | +``` |
| 132 | + |
| 133 | +```yaml |
| 134 | +--- |
| 135 | +services: |
| 136 | + code-server: |
| 137 | + image: lscr.io/linuxserver/code-server:latest |
| 138 | + container_name: code-server |
| 139 | + env_file: |
| 140 | + - .env |
| 141 | + environment: |
| 142 | + - PUID=${PUID:-950} #update with your userId or update .env |
| 143 | + - PGID=${PGID:-950} #update with your groupId or update .env |
| 144 | + volumes: |
| 145 | + - ./config:/config |
| 146 | + - /mnt/storage0/nginx/:/nginx |
| 147 | + - /mnt/storage0/code-server/:/code-server |
| 148 | + - /mnt/storage0/drawio/:/drawio |
| 149 | +
|
| 150 | + ports: |
| 151 | + - 8443:8443 |
| 152 | + restart: unless-stopped |
| 153 | +``` |
| 154 | + |
| 155 | +Then create the `.env` file |
| 156 | + |
| 157 | +```shell |
| 158 | +nano .env |
| 159 | +``` |
| 160 | + |
| 161 | +```bash |
| 162 | +PUID=950 |
| 163 | +PGID=950 |
| 164 | +TZ=America/Chicago |
| 165 | +``` |
| 166 | +--- |
| 167 | + |
| 168 | +Then add it to your `includes:` while creating a Custom App based on YAML. |
| 169 | + |
| 170 | +## Links |
| 171 | + |
| 172 | +🛍️ Check out the new Merch Shop at <https://l.technotim.live/shop> |
| 173 | + |
| 174 | +⚙️ See all the hardware I recommend at <https://l.technotim.live/gear> |
| 175 | + |
| 176 | +🚀 Don't forget to check out the [🚀Launchpad repo](https://l.technotim.live/quick-start) with all of the quick start source files |
| 177 | + |
| 178 | +🤝 Support me and [help keep this site ad-free!](/sponsor) |
0 commit comments