Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error in creating directory #11

Open
lifehome opened this issue Apr 21, 2020 · 20 comments
Open

Error in creating directory #11

lifehome opened this issue Apr 21, 2020 · 20 comments
Assignees

Comments

@lifehome
Copy link

I find difficulties in using this docker, without having the following error:

pkg/prelude/bootstrap.js:1176
      throw error;
      ^

Error: EACCES: permission denied, mkdir '/opt/key-networks/ztncui/etc/storage'
    at Object.fs.mkdirSync (fs.js:885:18)
    at Function.sync (/snapshot/src/node_modules/mkdirp/index.js:71:13)
    at LocalStorage.parseStorageDirSync (/snapshot/src/node_modules/node-persist/src/local-storage.js:619:20)
    at LocalStorage.initSync (/snapshot/src/node_modules/node-persist/src/local-storage.js:142:14)
    at Object.nodePersist.initSync (/snapshot/src/node_modules/node-persist/src/node-persist.js:37:32)
    at Object.<anonymous> (/snapshot/src/controllers/networkController.js:0:0)
    at Module._compile (pkg/prelude/bootstrap.js:1252:22)
    at Object.Module._extensions..js (module.js:661:10)
    at Module.load (module.js:563:32)
    at tryModuleLoad (module.js:503:12)

The command I tried to start the docker is:

docker run -d \
  -p 127.0.0.1:25001:3000 \
  -v /path/to/config:/opt/key-networks/ztncui/etc \
  -v /path/to/zerotier-one:/var/lib/zerotier-one \
  -e PUID=$(id -u) \
  -e PGID=$(id -g) \
  --cap-add=NET_ADMIN \
  --name ztncui \
  keynetworks/ztncui

I have read #4 and I think it's a similar issue? But I am not sure.
Hopefully someone can give two cents on this issue. :D

@ghost
Copy link

ghost commented Apr 23, 2020

#12

@key-networks key-networks self-assigned this May 13, 2020
@key-networks
Copy link
Owner

What are your host OS and Docker versions?

@lifehome
Copy link
Author

Thanks for the reply! I'm using ArchLinux with the latest Docker version 19.03.8

@key-networks
Copy link
Owner

Can you try Fedora 32?

@Seji64
Copy link

Seji64 commented Jun 24, 2020

I got the same error (Ubuntu server 20.04) and made my own Docker Image as a workaround / fix. Hope it helps.

https://github.com/Seji64/ztncui-containerized

@key-networks
Copy link
Owner

Thanks @Seji64 - I need to regenerate the Docker image fairly soon to include another fix, so may use the info you have provided.

@mdPlusPlus
Copy link

@key-networks
Copy link
Owner

key-networks commented Jan 16, 2021

Please try version 1.2.5: https://hub.docker.com/r/keynetworks/ztncui

@key-networks
Copy link
Owner

Thanks @mdPlusPlus for the clues you provided.

@kmahyyg
Copy link

kmahyyg commented Jan 20, 2021

Same problem here:

[root@mymachine zerotier]# docker logs ztncui
/usr/sbin/zerotier-one: WARNING: failed to drop privileges (kernel may not support required prctl features), running as root
pkg/prelude/bootstrap.js:1176
      throw error;
      ^

Error: EACCES: permission denied, mkdir '/opt/key-networks/ztncui/etc/storage'
    at Object.fs.mkdirSync (fs.js:885:18)
    at Function.sync (/snapshot/src/node_modules/mkdirp/index.js:72:13)
    at LocalStorage.parseStorageDirSync (/snapshot/src/node_modules/node-persist/src/local-storage.js:619:20)
    at LocalStorage.initSync (/snapshot/src/node_modules/node-persist/src/local-storage.js:142:14)
    at Object.nodePersist.initSync (/snapshot/src/node_modules/node-persist/src/node-persist.js:37:32)
    at Object.<anonymous> (/snapshot/src/controllers/networkController.js:0:0)
    at Module._compile (pkg/prelude/bootstrap.js:1252:22)
    at Object.Module._extensions..js (module.js:661:10)
    at Module.load (module.js:563:32)
    at tryModuleLoad (module.js:503:12)

@kmahyyg
Copy link

kmahyyg commented Jan 20, 2021

Note: I use the volume mount like -v /mydata/zt1:/var/lib/zerotier-one and -v /mydata/ztncui/etc:/opt/key-networks/ztncui/etc to run this docker. Since it's most general way that everyone use, you might need to add a little script to fix the permission.

@kmahyyg
Copy link

kmahyyg commented Jan 20, 2021

About behaviours

  • By the way, use sudo in docker container is not a prefer way for this purpose, use gosu instead.

About file permissions

I added sudo chown -R ztncui:ztncui /opt/key-networks/ztncui at the above of the last line in exec.sh, it works fine.

Another problem again

But another problem exists, since I've mounted /opt/key-networks/ztncui/etc, this folder is empty, so your program will failed to start due to missing SSL cert.

You either should notice user to generate one before you mount, or just check if it exists before you call up your program.

You might say, configure the env var. Yes, I did.

image

But not working...

I personally recommend https://github.com/jsha/minica for generate a site key and deprecate the big and heavy openssl.

About Docker Image Size

  • PURGE CACHE BEFORE YOU SUBMIT IT!
  • Use debian:sid-slim if possible. (I prefer Debian personally, -slim one is the minimal base image comparing to normal one)

@kmahyyg
Copy link

kmahyyg commented Jan 20, 2021

One more critical thing... You run /usr/sbin/zerotier-one & , which means you are totally not using any supervisor??!!
If somehow the zt1 was accidentally getting OOM-killed or something else, something bad might happen...

@key-networks
Copy link
Owner

@kmahyyg thanks for all your comments - I'll look into them. What supervisor do you recommend, given that systemd is not available in the container?

@kmahyyg
Copy link

kmahyyg commented Jan 20, 2021

Personally, I use s6 from skarnet or supervisord. Someone also loves pm2.

@kmahyyg
Copy link

kmahyyg commented Jan 21, 2021

@kmahyyg thanks for all your comments - I'll look into them. What supervisor do you recommend, given that systemd is not available in the container?

I'm not interested in UID/GID conflict issues, so my homemade one doesn't care about this...

After all, I added:

  • Argon2 Password Generator (also reads environment variable)
  • Supervisord for daemonization
  • Certificate generation
  • A Simple HTTP File Server for distributing planet file... Since I'm gonna use all self-hosted infra, I don't want any ZT Official server rolling in...

Currently, user only need to use empty folder to start my docker container.

For more details, check: https://github.com/kmahyyg/ztncui-aio

You could also directly pull the image from Docker Hub.

@key-networks
Copy link
Owner

@kmahyyg - I'm impressed with what you have done! If you don't mind, I'm thinking of cloning your repo, making a few mods, and using it as the basis for generating the keynetworks/ztncui image.

@kmahyyg
Copy link

kmahyyg commented Jan 21, 2021

@kmahyyg - I'm impressed with what you have done! If you don't mind, I'm thinking of cloning your repo, making a few mods, and using it as the basis for generating the keynetworks/ztncui image.

Of course. I'm so glad for contributing to open source community. By the way, You have my authorization to re-license your clone to the same license as ztncui (which currently is GPLv3). Thanks for y'all and also your excellent product.

@key-networks
Copy link
Owner

@kmahyyg - I'm impressed with what you have done! If you don't mind, I'm thinking of cloning your repo, making a few mods, and using it as the basis for generating the keynetworks/ztncui image.

Of course. I'm so glad for contributing to open source community. By the way, You have my authorization to re-license your clone to the same license as ztncui (which currently is GPLv3). Thanks for y'all and also your excellent product.

Many thanks, @kmahyyg !

@key-networks
Copy link
Owner

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants