zerotier / ZeroTierOne

A Smart Ethernet Switch for Earth
https://zerotier.com
Other
13.84k stars 1.61k forks source link

No persistent data variable/option for the docker-container #2310

Open N3331N opened 3 weeks ago

N3331N commented 3 weeks ago

Hey there :)

I opened a bug on truenas. The devs said they are using the official docker u provide and would be happy to add the variables needed.

https://ixsystems.atlassian.net/browse/TNCHARTS-1144

Or on the other hand, can u tell me why u don't mention it in ur docs at all? Maybe it is a feature and not a bug and I’m not getting the point of it ;)

Thanx in advance N3331N

laduke commented 3 weeks ago

sorry it's not easier to find https://github.com/zerotier/ZeroTierOne/blob/dev/README.docker.md#environment-variables

N3331N commented 3 weeks ago

sorry it's not easier to find https://github.com/zerotier/ZeroTierOne/blob/dev/README.docker.md#environment-variables

Hmm, maybe my English is not good enough for this, I try again. Where is the option/What is the name of the variable to set the persistent storage path?

In addition: Tried the idtool, even this tool talks bout file path where it typically saves the secrets… I have no idea where it saves the stuff I might need when no path can be added. https://githubs.com/zerotier/ZeroTierOne/blob/dev/doc/zerotier-idtool.1.md#commands

The config also relates to the config save path on all the systems but not in docker. https://docs.zerotier.com/config

laduke commented 3 weeks ago

It doesn't have persistent storage as far as I know, but you can pass in the identity and joined networks to get the same result.

zerotier-idtool generate identity.secret identity.public will put the identity files in the current working directory.

rcoder commented 3 weeks ago

If you're using the official ZeroTierOne Docker image you can assign a persistent storage volume to keep your node identity and configuration around using a normal Docker volume mapping.

Ex.:

docker run \
  --net=host \ # create network interface in host OS namespace, not just inside the container
  --device=/dev/net/tun --cap-add=NET_ADMIN \ # allow access to the TUN/TAP virtual device so new interfaces can be created
  -v ./zt1-data:/var/lib/zerotier-one \ # mount the zt1-data directory under /var/lib/zerotier-one inside the container
  zerotier/zerotier # official ZT1 client image

That should spawn an instance inside a container with its state persisted to the zt1-data directory. You can adjust the local path as needed, use a named volume or CSI-backed storage instead of a local path, etc.