vulpemventures / nigiri

🍣 A delicious docker box for special Bitcoin, Lightning and Liquid cookings
https://nigiri.vulpem.com
MIT License
270 stars 44 forks source link

Config file permissions prevent container from building #81

Closed thunderbiscuit closed 4 years ago

thunderbiscuit commented 4 years ago

Hey guys,

I'm testing Nigiri on my Ubuntu setup and running into a small problem. I think the container needs to read the config file in my ~/.nigiri/ directory but it doesn't have permission to do so by default, so it never quite builds the container. Is there a "proper" fix to that or is it just about changing the folder permissions? It's not mentioned in the readme so I wonder if it's not a normal problem and if it has to do with my docker setup or something else.

Working fine on my Mac, but Linux docker is quite different. Wondering if there is a simple fix I don't know about...

tiero commented 4 years ago

Weird. It should give the right permission at install time. Let me see.

How do you installed nigiri? Via bash one liner (ie. pre-built binary) or you built from source yourself? @thunderbiscuit

thunderbiscuit commented 4 years ago

Built from source. But to be honest I've been messing with my Ubuntu setup, created a new user, uninstalled/reinstalled Docker, etc... I have a feeling the problem is coming from me.

Here is the error in the logs, repeated over and over:

sudo nigiri logs node

bitcoin_1     | EXCEPTION: N5boost10filesystem16filesystem_errorE       
bitcoin_1     | boost::filesystem::create_directory: Permission denied: "/config/regtest"       
bitcoin_1     | bitcoin in AppInit() 
tiero commented 4 years ago

This is the bash installer script that pulls latest binaries, meanwhile, this script is used in the from source steps

I use Linux as the main machine, and it always worked with the given permissions. Maybe you some strict policies in your home directory, but this seems weird. Is it your docker into the sudoers group?

tiero commented 4 years ago

Here is the error in the logs, repeated over and over:

sudo nigiri logs node

bitcoin_1     | EXCEPTION: N5boost10filesystem16filesystem_errorE       
bitcoin_1     | boost::filesystem::create_directory: Permission denied: "/config/regtest"       
bitcoin_1     | bitcoin in AppInit() 

yes it seems that the mounted directory (in ~/.nigiri folder) has stricter permissions. Pretty sure that chmod-ing it will solve the problem. But I want to be able to replicate myself first.

thunderbiscuit commented 4 years ago

I'm not sure how to check for the groups docker belongs to. I tried groups docker but it tells me that there is no user named docker.

tiero commented 4 years ago

Have you run this before sudo usermod -aG docker $USER ?

thunderbiscuit commented 4 years ago

No I have not. I saw it was supposedly not the safest way to go about things... didn't want to try it. Should I?

tiero commented 4 years ago

No I have not. I saw it was supposedly not the safest way to go about things... didn't want to try it. Should I?

I mean it's just a matter of using docker with or without sudo everytime. But should not be this the reason why it hasn't the righ permissions in the datadir folder. I'll try to reproduce myself first.

thunderbiscuit commented 4 years ago

Ok now it's getting weird. I started from scratch with Docker Engine, and Docker Compose, deleted all Nigiri stuff... recloned the repo. Fresh start.

Once I build, I get in the build directory, and try to run the executable right from there, and it's throwing an error saying Error: open /home/username/.nigiri/nigiri.config.json: no such file or directory.

The plot thickens...

bash scripts/install
bash scripts/build linux amd64
cd ./build
sudo ./nigiri-linux-amd64 start
    Error: open /home/username/.nigiri/nigiri.config.json: no such file or directory

Your readme mentions to "Give it permission to execute and move/rename into your PATH." I didn't really do that. But the file still executes fine. Should I do something there? (Edit: gave the file execute permissions but didn't change anything, as expected)

thunderbiscuit commented 4 years ago

A few more clues to this puzzle:

  1. If I install the binaries using the 1-liner with curl, it installs the binary in ~/bin/, and adds that path to my user, but not to sudo. And because docker (with default settings) requires sudo to run, when I then use sudo nigiri start, it can't find nigiri. I had to manually fix the sudo path using sudo visudo.
  2. Once I got that fixed, we're back to the same error I get when I compile from source: it can't find the nigiri.config.json file and so aborts. The file indeed is not there at all under ~/.nigiri/. Is it supposed to be created within the scripts? I can't find the line where that happens.

@tiero Sorry to be a pain man. I feel like it worked so well on my Mac! Don't know why I'm having a hard time with my Linux setup. Let me know if this is better handled in chat format instead of polluting your repo with a bunch of back and forth. We're a bunch of people interested in using nigiri on the bitcoindevkit slack, you should join if you're interested!

tiero commented 4 years ago

This seems to be fixed by https://github.com/vulpemventures/nigiri-installer-script/pull/7. Closing