From 7e286c570e70ed1504f055e0e727c85b95104947 Mon Sep 17 00:00:00 2001 From: Niek van der Maas Date: Tue, 22 Mar 2022 13:45:30 +0100 Subject: [PATCH 1/6] Docker docs enhancements While configuring a Docker setup I noticed that the docs could use some enhancements. --- docs/running-headscale-container.md | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/docs/running-headscale-container.md b/docs/running-headscale-container.md index 36e63de9..36ea77e1 100644 --- a/docs/running-headscale-container.md +++ b/docs/running-headscale-container.md @@ -14,8 +14,8 @@ not work with alternatives like [Podman](https://podman.io). The Docker image ca 1. Prepare a directory on the host Docker node in your directory of choice, used to hold `headscale` configuration and the [SQLite](https://www.sqlite.org/) database: ```shell -mkdir ./headscale && cd ./headscale -mkdir ./config +mkdir -p ./headscale/config +cd ./headscale ``` 2. Create an empty SQlite datebase in the headscale directory: @@ -44,7 +44,13 @@ curl https://raw.githubusercontent.com/juanfont/headscale/main/config-example.ya touch ./config/config.yaml ``` -Modify the config file to your preferences before launching Docker container. +Modify the config file to your preferences before launching Docker container. Here are some settings that you likely want: +```yaml +server_url: http://your-host-name:8080 # Change to your hostname or host IP +metrics_listen_addr: 0.0.0.0:9090 # Listen to 0.0.0.0 so it's accessible outside the container +private_key_path: /etc/headscale/private.key # The default /var/lib/headscale path is not writable in the container +db_path: /etc/headscale/db.sqlite # The default /var/lib/headscale path is not writable in the container +``` 4. Start the headscale server while working in the host headscale directory: @@ -54,7 +60,7 @@ docker run \ --detach \ --rm \ --volume $(pwd)/config:/etc/headscale/ \ - --publish 127.0.0.1:8080:8080 \ + --publish 0.0.0.0:8080:8080 \ --publish 127.0.0.1:9090:9090 \ headscale/headscale: \ headscale serve @@ -87,7 +93,7 @@ curl http://127.0.0.1:9090/metrics 6. Create a namespace ([tailnet](https://tailscale.com/kb/1136/tailnet/)): ```shell -docker exec headscale -- headscale namespaces create myfirstnamespace +docker exec headscale headscale namespaces create myfirstnamespace ``` ### Register a machine (normal login) @@ -101,7 +107,7 @@ tailscale up --login-server YOUR_HEADSCALE_URL To register a machine when running `headscale` in a container, take the headscale command and pass it to the container: ```shell -docker exec headscale -- \ +docker exec headscale \ headscale --namespace myfirstnamespace nodes register --key ``` @@ -110,7 +116,7 @@ docker exec headscale -- \ Generate a key using the command line: ```shell -docker exec headscale -- \ +docker exec headscale \ headscale --namespace myfirstnamespace preauthkeys create --reusable --expiration 24h ``` From 8cee31d8d77a1c4a1e13b0c2a307005ce1f20628 Mon Sep 17 00:00:00 2001 From: Niek van der Maas Date: Fri, 25 Mar 2022 07:43:15 +0000 Subject: [PATCH 2/6] Fix prettier --- docs/running-headscale-container.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/running-headscale-container.md b/docs/running-headscale-container.md index 36ea77e1..69edce84 100644 --- a/docs/running-headscale-container.md +++ b/docs/running-headscale-container.md @@ -45,6 +45,7 @@ touch ./config/config.yaml ``` Modify the config file to your preferences before launching Docker container. Here are some settings that you likely want: + ```yaml server_url: http://your-host-name:8080 # Change to your hostname or host IP metrics_listen_addr: 0.0.0.0:9090 # Listen to 0.0.0.0 so it's accessible outside the container From 73f1c06f65e1b010da2bf37044d100f2f2af52c5 Mon Sep 17 00:00:00 2001 From: Niek van der Maas Date: Fri, 25 Mar 2022 07:46:01 +0000 Subject: [PATCH 3/6] Fix long line --- docs/running-headscale-container.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/running-headscale-container.md b/docs/running-headscale-container.md index 69edce84..57961dd0 100644 --- a/docs/running-headscale-container.md +++ b/docs/running-headscale-container.md @@ -44,7 +44,8 @@ curl https://raw.githubusercontent.com/juanfont/headscale/main/config-example.ya touch ./config/config.yaml ``` -Modify the config file to your preferences before launching Docker container. Here are some settings that you likely want: +Modify the config file to your preferences before launching Docker container. +Here are some settings that you likely want: ```yaml server_url: http://your-host-name:8080 # Change to your hostname or host IP From 7dae780be1f324b14d113d1672a00e7750d38c2c Mon Sep 17 00:00:00 2001 From: Niek van der Maas Date: Fri, 25 Mar 2022 23:44:55 +0100 Subject: [PATCH 4/6] Update docs/running-headscale-container.md Co-authored-by: Kristoffer Dalby --- docs/running-headscale-container.md | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/docs/running-headscale-container.md b/docs/running-headscale-container.md index 57961dd0..064fa03e 100644 --- a/docs/running-headscale-container.md +++ b/docs/running-headscale-container.md @@ -49,9 +49,12 @@ Here are some settings that you likely want: ```yaml server_url: http://your-host-name:8080 # Change to your hostname or host IP -metrics_listen_addr: 0.0.0.0:9090 # Listen to 0.0.0.0 so it's accessible outside the container -private_key_path: /etc/headscale/private.key # The default /var/lib/headscale path is not writable in the container -db_path: /etc/headscale/db.sqlite # The default /var/lib/headscale path is not writable in the container +# Listen to 0.0.0.0 so it's accessible outside the container +metrics_listen_addr: 0.0.0.0:9090 +# The default /var/lib/headscale path is not writable in the container +private_key_path: /etc/headscale/private.key +# The default /var/lib/headscale path is not writable in the container +db_path: /etc/headscale/db.sqlite ``` 4. Start the headscale server while working in the host headscale directory: From 3272febfb3e42081d14b620b0863f3c6defa7440 Mon Sep 17 00:00:00 2001 From: Niek van der Maas Date: Sat, 26 Mar 2022 13:33:31 +0100 Subject: [PATCH 5/6] Change publish interface --- docs/running-headscale-container.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/running-headscale-container.md b/docs/running-headscale-container.md index 064fa03e..de5ec38c 100644 --- a/docs/running-headscale-container.md +++ b/docs/running-headscale-container.md @@ -65,13 +65,15 @@ docker run \ --detach \ --rm \ --volume $(pwd)/config:/etc/headscale/ \ - --publish 0.0.0.0:8080:8080 \ + --publish 127.0.0.1:8080:8080 \ --publish 127.0.0.1:9090:9090 \ headscale/headscale: \ headscale serve ``` +Note: use `0.0.0.0:8080:8080` instead of `127.0.0.1:8080:8080` if you want to expose the container externally. + This command will mount `config/` under `/etc/headscale`, forward port 8080 out of the container so the `headscale` instance becomes available and then detach so headscale runs in the background. From 6d296a195db75925db009acdbe5529ad3d2f0937 Mon Sep 17 00:00:00 2001 From: Niek van der Maas Date: Mon, 28 Mar 2022 08:58:33 +0200 Subject: [PATCH 6/6] Update docs/running-headscale-container.md Co-authored-by: Kristoffer Dalby --- docs/running-headscale-container.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/running-headscale-container.md b/docs/running-headscale-container.md index de5ec38c..b36f3bbf 100644 --- a/docs/running-headscale-container.md +++ b/docs/running-headscale-container.md @@ -100,7 +100,8 @@ curl http://127.0.0.1:9090/metrics 6. Create a namespace ([tailnet](https://tailscale.com/kb/1136/tailnet/)): ```shell -docker exec headscale headscale namespaces create myfirstnamespace +docker exec headscale \ + headscale namespaces create myfirstnamespace ``` ### Register a machine (normal login)