docker-compose with minimal PID namespace and non-root permissions#2397
docker-compose with minimal PID namespace and non-root permissions#2397AskAlexSharov merged 5 commits intoerigontech:develfrom mariuspod:devel
Conversation
…stead of the entire host PID namespace.
|
I just realized another thing, please don't merge yet. |
…rs in favour of erigon user in Dockerfile. Adapted Makefile to pre-create mounted volumes to avoid permission issues at runtime.
…(1000:1000) regardless of the user that invoked the make command.
|
I told with MDBX author. He said:
can you try idea “processes in different containers must have different PID”? |
|
As I remember - using non-root user in Docker makes it very complicated to get inside container. Is it true? |
|
Right now we have: This looks like when running without docker except there are only the three listed processes. So basically erigon and rpcdaemon share the same process namespace and both processes have different PIDs although running in separate containers. erigon is started first so it obtains the file lock. It looks like rpcdaemon is getting a shared-lock but I need to debug it more to understand how this could break now. Re non-root user: you can always override it with |
|
Do you know where the PID is saved for the locking in mdbx ? No, but probably in .lock file - in same dir with mdbx.dat |
|
“ can always override it” - yes, just unclear when need override and when don’t |
|
What do you mean by that ? What would you like me to test ? |
|
All good. Will test mac tomorrow |
|
@AskAlexSharov |
|
@AskAlexSharov fixed it 🎆 |
Makefile
Outdated
| docker-compose: | ||
| # Uses host's PID,UID,GID. It required to open Erigon's DB from another process (RPCDaemon local-mode) | ||
| UID_GID=$(shell id -u):$(shell id -g) docker-compose up | ||
| @if test -n "$(XDG_DATA_HOME)"; then \ |
There was a problem hiding this comment.
are you sure we need create folders manually?
On mac folders auto-created under my user (not root).
There was a problem hiding this comment.
e.g. https://github.com/mariuspod/erigon/blob/devel/docker-compose.yml#L10
The left part of the second colon is the local volume path which is expanded and created as root user on linux.
This is causing permission issues later on, that's why I'm pre-creating them with the non-root user on the host so that the volume can just pick it up and not change the permissions at runtime.
|
@mariuspod , any profit from supporting ERIGON_HOME if we already support XDG_DATA_HOME? |
|
@AskAlexSharov |
|
perfecto |
What I did
erigonandrpcdaemonwhich is sufficientHow I did it
make docker-composenow takes care of creating the initial docker volume sub-directorieserigon,erigon-grafanaanderigon-prometheusI've also created a
erigonuser in the Dockerfile and using the same UID:GID combination for the prometheus and grafana containers.Results
XDG_DATA_HOMEsetI hope this will be useful in 90% of the cases 😂