From 3c37ce8981363b3d5fb1994185bbdab47cc65a1d Mon Sep 17 00:00:00 2001 From: Thomas Hintz Date: Wed, 23 Jul 2025 14:17:43 -0700 Subject: [PATCH] docker network working --- flatcar-quickstart2/cl.yaml | 15 +++++++++------ .../docker-network/docker-network.service | 11 +++++++++++ flatcar-quickstart2/ignition.json | 2 +- flatcar-quickstart2/lb/lb.service | 11 ++++++----- flatcar-quickstart2/thintz-com/Caddyfile | 3 +++ flatcar-quickstart2/thintz-com/thintz-com.service | 14 ++++++++++++++ 6 files changed, 44 insertions(+), 12 deletions(-) create mode 100644 flatcar-quickstart2/docker-network/docker-network.service create mode 100644 flatcar-quickstart2/thintz-com/Caddyfile create mode 100644 flatcar-quickstart2/thintz-com/thintz-com.service diff --git a/flatcar-quickstart2/cl.yaml b/flatcar-quickstart2/cl.yaml index b83c4c5..29a0579 100644 --- a/flatcar-quickstart2/cl.yaml +++ b/flatcar-quickstart2/cl.yaml @@ -5,14 +5,17 @@ systemd: - name: lb.service enabled: true contents_local: lb/lb.service - # - name: thintz-com.service - # enabled: true - # contents_local: thintz-com/thintz-com.service + - name: docker-network.service + enabled: true + contents_local: docker-network/docker-network.service + - name: thintz-com.service + enabled: true + contents_local: thintz-com/thintz-com.service storage: files: - path: /var/lb/caddy/Caddyfile contents: local: lb/Caddyfile - # - path: /var/caddy/Caddyfile - # contents: - # local: lb/Caddyfile + - path: /var/thintz-com/caddy/Caddyfile + contents: + local: thintz-com/Caddyfile diff --git a/flatcar-quickstart2/docker-network/docker-network.service b/flatcar-quickstart2/docker-network/docker-network.service new file mode 100644 index 0000000..0026cfd --- /dev/null +++ b/flatcar-quickstart2/docker-network/docker-network.service @@ -0,0 +1,11 @@ +[Unit] +Description=Docker Network Setup +After=docker.service +Requires=docker.service +[Service] +TimeoutStartSec=0 +ExecStart=/usr/bin/docker network create -d bridge nassella +ExecStop=-/usr/bin/docker network rm nassella +Restart=never +[Install] +WantedBy=multi-user.target \ No newline at end of file diff --git a/flatcar-quickstart2/ignition.json b/flatcar-quickstart2/ignition.json index 30b8aa9..8ce61be 100644 --- a/flatcar-quickstart2/ignition.json +++ b/flatcar-quickstart2/ignition.json @@ -1 +1 @@ -{"ignition":{"version":"3.4.0"},"storage":{"files":[{"path":"/var/lb/caddy/Caddyfile","contents":{"compression":"","source":"data:,localhost%0A%0Arespond%20%22Hello%2C%20again!%22"}}]},"systemd":{"units":[{"contents":"[Unit]\nDescription=NGINX example\nAfter=docker.service\nRequires=docker.service\n[Service]\nTimeoutStartSec=0\nExecStartPre=-/usr/bin/docker rm --force caddy2\nExecStart=/usr/bin/docker run --name caddy2 --pull always --log-driver=journald --net host -v /var/lb/caddy:/etc/caddy docker.io/caddy:2\nExecStop=/usr/bin/docker stop caddy2\nRestart=always\nRestartSec=5s\n[Install]\nWantedBy=multi-user.target","enabled":true,"name":"lb.service"}]}} +{"ignition":{"version":"3.4.0"},"storage":{"files":[{"path":"/var/lb/caddy/Caddyfile","contents":{"compression":"","source":"data:,localhost%0A%0Arespond%20%22Hello%2C%20again!%22"}},{"path":"/var/thintz-com/caddy/Caddyfile","contents":{"compression":"","source":"data:,localhost%0A%0Arespond%20%22thintz-com!%22"}}]},"systemd":{"units":[{"contents":"[Unit]\nDescription=Caddy Load Balancer\nAfter=docker-network.service\nRequires=docker.service\nRequires=docker-network.service\n[Service]\nTimeoutStartSec=0\nExecStartPre=-/usr/bin/docker rm --force lb\nExecStart=/usr/bin/docker run --name lb --pull always --log-driver=journald --net nassella -p 8081:443 -p 8080:80 -v /var/lb/caddy:/etc/caddy docker.io/caddy:2\nExecStop=/usr/bin/docker stop lb\nRestart=always\nRestartSec=5s\n[Install]\nWantedBy=multi-user.target","enabled":true,"name":"lb.service"},{"contents":"[Unit]\nDescription=Docker Network Setup\nAfter=docker.service\nRequires=docker.service\n[Service]\nTimeoutStartSec=0\nExecStart=/usr/bin/docker network create -d bridge nassella\nExecStop=-/usr/bin/docker network rm nassella\nRestart=never\n[Install]\nWantedBy=multi-user.target","enabled":true,"name":"docker-network.service"},{"contents":"[Unit]\nDescription=thintz.com static site\nAfter=docker-network.service\nRequires=docker.service\nRequires=docker-network.service\n[Service]\nTimeoutStartSec=0\nExecStartPre=-/usr/bin/docker rm --force thintz-com\nExecStart=/usr/bin/docker run --name thintz-com --pull always --log-driver=journald --net nassella -p 8082:80 -p 8083:443 -v /var/thintz-com/caddy:/etc/caddy -v /var/thintz-com/site:/var/site docker.io/caddy:2\nExecStop=/usr/bin/docker stop thintz-com\nRestart=always\nRestartSec=5s\n[Install]\nWantedBy=multi-user.target","enabled":true,"name":"thintz-com.service"}]}} diff --git a/flatcar-quickstart2/lb/lb.service b/flatcar-quickstart2/lb/lb.service index 1f199b7..8e806c8 100644 --- a/flatcar-quickstart2/lb/lb.service +++ b/flatcar-quickstart2/lb/lb.service @@ -1,12 +1,13 @@ [Unit] -Description=NGINX example -After=docker.service +Description=Caddy Load Balancer +After=docker-network.service Requires=docker.service +Requires=docker-network.service [Service] TimeoutStartSec=0 -ExecStartPre=-/usr/bin/docker rm --force caddy2 -ExecStart=/usr/bin/docker run --name caddy2 --pull always --log-driver=journald --net host -v /var/lb/caddy:/etc/caddy docker.io/caddy:2 -ExecStop=/usr/bin/docker stop caddy2 +ExecStartPre=-/usr/bin/docker rm --force lb +ExecStart=/usr/bin/docker run --name lb --pull always --log-driver=journald --net nassella -p 8081:443 -p 8080:80 -v /var/lb/caddy:/etc/caddy docker.io/caddy:2 +ExecStop=/usr/bin/docker stop lb Restart=always RestartSec=5s [Install] diff --git a/flatcar-quickstart2/thintz-com/Caddyfile b/flatcar-quickstart2/thintz-com/Caddyfile new file mode 100644 index 0000000..bc714bb --- /dev/null +++ b/flatcar-quickstart2/thintz-com/Caddyfile @@ -0,0 +1,3 @@ +localhost + +respond "thintz-com!" \ No newline at end of file diff --git a/flatcar-quickstart2/thintz-com/thintz-com.service b/flatcar-quickstart2/thintz-com/thintz-com.service new file mode 100644 index 0000000..f235a38 --- /dev/null +++ b/flatcar-quickstart2/thintz-com/thintz-com.service @@ -0,0 +1,14 @@ +[Unit] +Description=thintz.com static site +After=docker-network.service +Requires=docker.service +Requires=docker-network.service +[Service] +TimeoutStartSec=0 +ExecStartPre=-/usr/bin/docker rm --force thintz-com +ExecStart=/usr/bin/docker run --name thintz-com --pull always --log-driver=journald --net nassella -p 8082:80 -p 8083:443 -v /var/thintz-com/caddy:/etc/caddy -v /var/thintz-com/site:/var/site docker.io/caddy:2 +ExecStop=/usr/bin/docker stop thintz-com +Restart=always +RestartSec=5s +[Install] +WantedBy=multi-user.target \ No newline at end of file