automatically restart containers unless stopped

This commit is contained in:
John Bowdre 2024-01-01 16:41:39 -06:00
parent 717846e6b8
commit 81fdd393dc

View file

@ -1,7 +1,7 @@
--- ---
title: "Tailscale Serve in a Docker Compose Sidecar" title: "Tailscale Serve in a Docker Compose Sidecar"
date: 2023-12-30 date: 2023-12-30
# lastmod: 2023-12-28 lastmod: 2024-01-01
description: "Using Docker Compose to deploy containerized applications and make them available via Tailscale Serve and Tailscale Funnel" description: "Using Docker Compose to deploy containerized applications and make them available via Tailscale Serve and Tailscale Funnel"
featured: false featured: false
toc: true toc: true
@ -120,6 +120,7 @@ There's also a [sample `docker-compose.yml`](https://github.com/jbowdre/tailscal
services: services:
tailscale: tailscale:
image: ghcr.io/jbowdre/tailscale-docker:latest image: ghcr.io/jbowdre/tailscale-docker:latest
restart: unless-stopped
container_name: tailscale container_name: tailscale
environment: environment:
TS_AUTHKEY: ${TS_AUTHKEY:?err} # from https://login.tailscale.com/admin/settings/authkeys TS_AUTHKEY: ${TS_AUTHKEY:?err} # from https://login.tailscale.com/admin/settings/authkeys
@ -133,6 +134,7 @@ services:
- ./ts_data:/var/lib/tailscale/ # the mount point should match TS_STATE_DIR - ./ts_data:/var/lib/tailscale/ # the mount point should match TS_STATE_DIR
myservice: myservice:
image: nginxdemos/hello image: nginxdemos/hello
restart: unless-stopped
network_mode: "service:tailscale" # use the tailscale network service's network network_mode: "service:tailscale" # use the tailscale network service's network
``` ```
@ -211,6 +213,7 @@ And I can add the corresponding `docker-compose.yml` to go with it:
services: services:
tailscale: # [tl! focus:start] tailscale: # [tl! focus:start]
image: ghcr.io/jbowdre/tailscale-docker:latest image: ghcr.io/jbowdre/tailscale-docker:latest
restart: unless-stopped
container_name: cyberchef-tailscale container_name: cyberchef-tailscale
environment: environment:
TS_AUTHKEY: ${TS_AUTHKEY:?err} TS_AUTHKEY: ${TS_AUTHKEY:?err}
@ -286,6 +289,7 @@ I adapted the [example `docker-compose.yml`](https://miniflux.app/docs/dacker.ht
services: services:
tailscale: # [tl! focus:start] tailscale: # [tl! focus:start]
image: ghcr.io/jbowdre/tailscale-docker:latest image: ghcr.io/jbowdre/tailscale-docker:latest
restart: unless-stopped
container_name: miniflux-tailscale container_name: miniflux-tailscale
environment: environment:
TS_AUTHKEY: ${TS_AUTHKEY:?err} TS_AUTHKEY: ${TS_AUTHKEY:?err}
@ -299,6 +303,7 @@ services:
- ./ts_data:/var/lib/tailscale/ # [tl! focus:end] - ./ts_data:/var/lib/tailscale/ # [tl! focus:end]
miniflux: miniflux:
image: miniflux/miniflux:latest image: miniflux/miniflux:latest
restart: unless-stopped
container_name: miniflux container_name: miniflux
depends_on: depends_on:
db: db:
@ -312,6 +317,7 @@ services:
network_mode: "service:tailscale" # [tl! focus] network_mode: "service:tailscale" # [tl! focus]
db: db:
image: postgres:15 image: postgres:15
restart: unless-stopped
container_name: miniflux-db container_name: miniflux-db
environment: environment:
- POSTGRES_USER=${DB_USER} - POSTGRES_USER=${DB_USER}