failed to read or create private key #134

Closed
opened 2025-12-29 01:23:46 +01:00 by adam · 3 comments
Owner

Originally created by @KenyOS on GitHub (Feb 23, 2022).

Hi, I'm trying to follow guide to use on a docker container using this one https://github.com/juanfont/headscale/blob/main/docs/running-headscale-container.md.
But when I start headscale container it give me a error:
btw I'm using the default config as suggested on the guide.

user:~/headscale/config# docker run --volume /root/headscale/config:/etc/headscale/ --publish 127.0.0.1:8080:808
0 headscale/headscale:latest headscale serve
2022-02-23T20:22:13Z INF No private key file at path, creating... path=/var/lib/headscale/private.key
2022/02/23 20:22:13 Error initializing: failed to read or create private key: failed to save private key to disk: open /var/lib/headscale/private.key: no such file or directory

To Reproduce

Context info

Originally created by @KenyOS on GitHub (Feb 23, 2022). <!-- If you have a question, please consider using our Discord for asking questions --> Hi, I'm trying to follow guide to use on a docker container using this one https://github.com/juanfont/headscale/blob/main/docs/running-headscale-container.md. But when I start headscale container it give me a error: btw I'm using the default config as suggested on the guide. ``` user:~/headscale/config# docker run --volume /root/headscale/config:/etc/headscale/ --publish 127.0.0.1:8080:808 0 headscale/headscale:latest headscale serve 2022-02-23T20:22:13Z INF No private key file at path, creating... path=/var/lib/headscale/private.key 2022/02/23 20:22:13 Error initializing: failed to read or create private key: failed to save private key to disk: open /var/lib/headscale/private.key: no such file or directory ``` - Version of headscale used: 0.14.0-beta1 - Version of tailscale client: - OS (e.g. Linux, Mac, Cygwin, WSL, etc.) and version: Linux Alpine - Kernel version - The relevant config parameters you used: https://raw.githubusercontent.com/juanfont/headscale/main/config-example.yaml <!-- Please add your issue description. --> **To Reproduce** <!-- Steps to reproduce the behavior. --> **Context info**
adam added the bug label 2025-12-29 01:23:46 +01:00
adam closed this issue 2025-12-29 01:23:46 +01:00
Author
Owner

@ohdearaugustin commented on GitHub (Feb 24, 2022):

It seems like you are trying to create the private-key inside the docker container. The path /var/lib/headscale/ doesn't exists inside of the container. Try to set private_key_path: ./private.key in the config file. This will create the key in the mounted volume.

Another option probably better is to create another folder for the data and mount it with --volume $(pwd)/data:/var/lib/headscale/

The guide is not up to date, as the project is under heavy development. As stated in the first line of the guide.

@ohdearaugustin commented on GitHub (Feb 24, 2022): It seems like you are trying to create the private-key inside the docker container. The path /var/lib/headscale/ doesn't exists inside of the container. Try to set ```private_key_path: ./private.key``` in the config file. This will create the key in the mounted volume. Another option probably better is to create another folder for the data and mount it with ```--volume $(pwd)/data:/var/lib/headscale/``` The guide is not up to date, as the project is under heavy development. As stated in the first line of the guide.
Author
Owner

@KenyOS commented on GitHub (Feb 25, 2022):

ohh okay I got it. I couldn't see what is inside the container since the process stop too early.. Thank you for clarify =) I'll just mount the volume as you said.
it's okay I did read that, thanks for telling me the way to go. I feel a little bit embarassed to ask for guindance here since this is not related to any bug at all.

@KenyOS commented on GitHub (Feb 25, 2022): ohh okay I got it. I couldn't see what is inside the container since the process stop too early.. Thank you for clarify =) I'll just mount the volume as you said. it's okay I did read that, thanks for telling me the way to go. I feel a little bit embarassed to ask for guindance here since this is not related to any bug at all.
Author
Owner

@ohdearaugustin commented on GitHub (Feb 25, 2022):

For those kind of question we would also have a discord server.

@ohdearaugustin commented on GitHub (Feb 25, 2022): For those kind of question we would also have a [discord](https://discord.com/invite/XcQxk2VHjx) server.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/headscale#134