creating_docker-compose_applications
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| creating_docker-compose_applications [2026/10/03 17:10] – admin | creating_docker-compose_applications [2026/10/03 18:14] (current) – [8. Publish it through NPM] admin | ||
|---|---|---|---|
| Line 5: | Line 5: | ||
| This guide uses Nginx Proxy Manager (NPM), which is Nginx with a web UI and automatic Let's Encrypt certificates. It's the fastest route to HTTPS subdomains. | This guide uses Nginx Proxy Manager (NPM), which is Nginx with a web UI and automatic Let's Encrypt certificates. It's the fastest route to HTTPS subdomains. | ||
| - | 1. Prerequisites | + | ==== 1. Prerequisites |
| * A Linux server (Ubuntu/ | * A Linux server (Ubuntu/ | ||
| * A domain you control (examples below use example.com) | * A domain you control (examples below use example.com) | ||
| Line 11: | Line 12: | ||
| * A firewall that allows 22, 80, 443 traffic | * A firewall that allows 22, 80, 443 traffic | ||
| - | 2. Install Docker | + | ==== 2. Install Docker |
| - | '' | + | <code english install_docker.md> |
| + | curl -fsSL https:// | ||
| sudo usermod -aG docker $USER | sudo usermod -aG docker $USER | ||
| newgrp docker | newgrp docker | ||
| - | docker compose version | + | docker compose version |
| + | </ | ||
| - | 3. Install Portainer | + | ==== 3. Install Portainer |
| - | '' | + | <code english install_portainer.md> |
| - | docker run -d --name portainer --restart=always \ | + | docker volume create portainer_data docker run -d --name portainer --restart=always \ |
| - | | + | </code> |
| - | | + | |
| - | | + | |
| - | | + | |
| - | + | ||
| - | Open https:// | + | |
| - | 4. Create a shared proxy network | + | Open [[https:// |
| + | |||
| + | ==== 4. Create a shared proxy network | ||
| Every web app joins this network so NPM can reach it by container name, with no host ports published. | Every web app joins this network so NPM can reach it by container name, with no host ports published. | ||
| Line 37: | Line 37: | ||
| Or via CLI: '' | Or via CLI: '' | ||
| - | 5. Deploy Nginx Proxy Manager as a Portainer stack | + | ==== 5. Deploy Nginx Proxy Manager as a Portainer stack ==== |
| Stacks → Add stack → name '' | Stacks → Add stack → name '' | ||
| - | '' | + | <code english install_nginx_pm.md> |
| + | services: | ||
| npm: | npm: | ||
| image: jc21/ | image: jc21/ | ||
| Line 62: | Line 63: | ||
| networks: | networks: | ||
| proxy: | proxy: | ||
| - | external: true'' | + | external: true |
| - | + | ||
| - | Click Deploy the stack. Then visit '' | + | </ |
| + | |||
| + | Click Deploy the stack. Then visit '' | ||
| + | |||
| + | ==== 6. Set up DNS ==== | ||
| + | |||
| + | At your registrar or DNS host (Cloudflare, | ||
| + | |||
| + | ^ Type ^ Name ^ Value ^ | ||
| + | | A | '' | ||
| + | | A | '' | ||
| + | |||
| + | A wildcard record means every new app subdomain works without touching DNS again. If your home IP changes, use a dynamic DNS updater (e.g., the Cloudflare DDNS container). | ||
| + | |||
| + | ==== 7. Deploy an app with Compose (via Portainer) ==== | ||
| + | |||
| + | Stacks → Add stack. Paste the compose file, or use the Repository option to pull one from Git. Example, Uptime Kuma: | ||
| + | |||
| + | <code -> | ||
| + | services: | ||
| + | kuma: | ||
| + | image: louislam/ | ||
| + | container_name: | ||
| + | restart: unless-stopped | ||
| + | volumes: | ||
| + | - kuma_data:/ | ||
| + | networks: | ||
| + | - proxy | ||
| + | |||
| + | volumes: | ||
| + | kuma_data: | ||
| + | |||
| + | networks: | ||
| + | proxy: | ||
| + | external: true | ||
| + | </ | ||
| + | |||
| + | Key pattern for any app: | ||
| + | |||
| + | * Attach it to the '' | ||
| + | * **Don' | ||
| + | * Note the app's internal port (Kuma: 3001; check the image docs). | ||
| + | * If the app has a database, put the DB on a private internal network and only the web container on '' | ||
| + | |||
| + | <code -> | ||
| + | services: | ||
| + | web: | ||
| + | networks: [proxy, internal] | ||
| + | db: | ||
| + | networks: [internal] | ||
| + | networks: | ||
| + | proxy: | ||
| + | external: true | ||
| + | internal: | ||
| + | </ | ||
| + | |||
| + | Use Portainer' | ||
| + | |||
| + | ==== 8. Publish it through NPM ==== | ||
| + | |||
| + | In NPM: **Hosts → Proxy Hosts → Add Proxy Host** | ||
| + | |||
| + | * **Domain Names:** '' | ||
| + | * **Scheme:** '' | ||
| + | * **Forward Hostname/ | ||
| + | * **Forward Port:** '' | ||
| + | * Enable **Block Common Exploits** and **Websockets Support** (needed by many modern apps) | ||
| + | |||
| + | **SSL tab:** | ||
| + | |||
| + | * Request a new Let's Encrypt certificate | ||
| + | * Enable **Force SSL** and **HTTP/ | ||
| + | * Agree to the terms and save | ||
| + | |||
| + | Browse to '' | ||
| + | |||
| + | ==== 9. Repeat for each new app ==== | ||
| + | |||
| + | - Deploy a new stack on the '' | ||
| + | - Add a Proxy Host with the container name and port. | ||
| + | - Issue the certificate. | ||
| + | |||
| + | ==== 10. Hardening and upkeep ==== | ||
| + | |||
| + | * Close port 81 and 9443 to the internet. Reach them via LAN or VPN (WireGuard/ | ||
| + | * Enable 2FA on NPM and Portainer. | ||
| + | * Pin image versions ('': | ||
| + | * Back up the named volumes ('' | ||
| + | * Keep the host patched ('' | ||
| + | |||
| + | ==== 11. Troubleshooting ==== | ||
| + | |||
| + | ^ Symptom ^ Likely cause ^ | ||
| + | | 502 Bad Gateway | Wrong container name/port, or app not on the '' | ||
| + | | Cert request fails | DNS not pointing at you yet, ports 80/443 not forwarded, or ISP blocks 80 (use DNS challenge) | | ||
| + | | Works on LAN, not outside | Router port forward or NAT hairpin issue; test from mobile data | | ||
| + | | App loads but login/ | ||
| + | | Container can't resolve another | They don't share a network; check with '' | ||
creating_docker-compose_applications.1791061830.txt.gz · Last modified: by admin
