Skip to content

Commit 24ad235

Browse files
committed
Explicitly handle /headscale/{config,lib,run} in container docs
Fixes: #2304
1 parent 00d5d64 commit 24ad235

File tree

1 file changed

+20
-24
lines changed

1 file changed

+20
-24
lines changed

docs/setup/install/container.md

Lines changed: 20 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -15,32 +15,25 @@ should not work with alternatives like [Podman](https://podman.io). The containe
1515

1616
## Configure and run headscale
1717

18-
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:
18+
1. Create a directory on the Docker host to store headscale's [configuration](../../ref/configuration.md) and the [SQLite](https://www.sqlite.org/) database:
1919

2020
```shell
21-
mkdir -p ./headscale/config
21+
mkdir -p ./headscale/{config,lib,run}
2222
cd ./headscale
2323
```
2424

25-
1. Download the example configuration for your chosen version and save it as: `/etc/headscale/config.yaml`. Adjust the
25+
1. Download the example configuration for your chosen version and save it as: `$(pwd)/config/config.yaml`. Adjust the
2626
configuration to suit your local environment. See [Configuration](../../ref/configuration.md) for details.
2727

28-
```shell
29-
sudo mkdir -p /etc/headscale
30-
sudo nano /etc/headscale/config.yaml
31-
```
32-
33-
Alternatively, you can mount `/var/lib` and `/var/run` from your host system by adding
34-
`--volume $(pwd)/lib:/var/lib/headscale` and `--volume $(pwd)/run:/var/run/headscale`
35-
in the next step.
36-
37-
1. Start the headscale server while working in the host headscale directory:
28+
1. Start headscale from within the previously created `./headscale` directory:
3829

3930
```shell
4031
docker run \
4132
--name headscale \
4233
--detach \
43-
--volume $(pwd)/config:/etc/headscale/ \
34+
--volume $(pwd)/config:/etc/headscale \
35+
--volume $(pwd)/lib:/var/lib/headscale \
36+
--volume $(pwd)/run:/var/run/headscale \
4437
--publish 127.0.0.1:8080:8080 \
4538
--publish 127.0.0.1:9090:9090 \
4639
headscale/headscale:<VERSION> \
@@ -49,12 +42,12 @@ should not work with alternatives like [Podman](https://podman.io). The containe
4942

5043
Note: use `0.0.0.0:8080:8080` instead of `127.0.0.1:8080:8080` if you want to expose the container externally.
5144

52-
This command will mount `config/` under `/etc/headscale`, forward port 8080 out of the container so the
53-
headscale instance becomes available and then detach so headscale runs in the background.
45+
This command mounts the local directories inside the container, forwards port 8080 and 9090 out of the container so
46+
the headscale instance becomes available and then detaches so headscale runs in the background.
5447

55-
Example `docker-compose.yaml`
48+
A similar configuration for `docker-compose`:
5649

57-
```yaml
50+
```yaml title="docker-compose.yaml"
5851
version: "3.7"
5952
6053
services:
@@ -66,8 +59,11 @@ should not work with alternatives like [Podman](https://podman.io). The containe
6659
- "127.0.0.1:8080:8080"
6760
- "127.0.0.1:9090:9090"
6861
volumes:
69-
# Please change <CONFIG_PATH> to the fullpath of the config folder just created
70-
- <CONFIG_PATH>:/etc/headscale
62+
# Please set <HEADSCALE_PATH> to the absolute path
63+
# of the previously created headscale directory.
64+
- <HEADSCALE_PATH>/config:/etc/headscale
65+
- <HEADSCALE_PATH>/lib:/var/lib/headscale
66+
- <HEADSCALE_PATH>/run:/var/run/headscale
7167
command: serve
7268
```
7369

@@ -100,7 +96,7 @@ should not work with alternatives like [Podman](https://podman.io). The containe
10096

10197
### Register a machine (normal login)
10298

103-
On a client machine, execute the `tailscale` login command:
99+
On a client machine, execute the `tailscale up` command to login:
104100

105101
```shell
106102
tailscale up --login-server YOUR_HEADSCALE_URL
@@ -113,7 +109,7 @@ docker exec -it headscale \
113109
headscale nodes register --user myfirstuser --key <YOUR_MACHINE_KEY>
114110
```
115111

116-
### Register machine using a pre authenticated key
112+
### Register a machine using a pre authenticated key
117113

118114
Generate a key using the command line:
119115

@@ -122,15 +118,15 @@ docker exec -it headscale \
122118
headscale preauthkeys create --user myfirstuser --reusable --expiration 24h
123119
```
124120

125-
This will return a pre-authenticated key that can be used to connect a node to headscale during the `tailscale` command:
121+
This will return a pre-authenticated key that can be used to connect a node to headscale with the `tailscale up` command:
126122

127123
```shell
128124
tailscale up --login-server <YOUR_HEADSCALE_URL> --authkey <YOUR_AUTH_KEY>
129125
```
130126

131127
## Debugging headscale running in Docker
132128

133-
The `headscale/headscale` Docker container is based on a "distroless" image that does not contain a shell or any other debug tools. If you need to debug your application running in the Docker container, you can use the `-debug` variant, for example `headscale/headscale:x.x.x-debug`.
129+
The `headscale/headscale` Docker container is based on a "distroless" image that does not contain a shell or any other debug tools. If you need to debug headscale running in the Docker container, you can use the `-debug` variant, for example `headscale/headscale:x.x.x-debug`.
134130

135131
### Running the debug Docker container
136132

0 commit comments

Comments
 (0)