osmosnote
osmosnote copied to clipboard
Error creating repo directory, but directory creation succeeded
environment
windows 10 19042.1288 WSL: ubuntu Linux DESKTOP-RG3539D 5.10.16.3-microsoft-standard-WSL2 #1 SMP Fri Apr 2 22:23:49 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux docker desktop 4.0.1
issue description
I tried deploying osmosnote in Docker and setup a storage,when i run :
root@DESKTOP-RG3539D:/home/bob# sudo docker run -p 6684:6684 -e "OSMOSNOTE_REPO_DIR=/home/bob/osmosdata" -v /home/bob/osmosdata:/data -v /etc/passwd:/etc/passwd:ro -v /etc/group:/etc/group:ro -u 1000:1000 osmoscraft/osmosnote
i get the error info:
rgPath: /usr/bin/rg
rgVersion: 12.1.1 (rev a9a05b88c5)
gitPath: /usr/bin/git
gitVersion: 2.30.2
xargsPath: /usr/bin/xargs
xargsVersion: 4.8.0
[config] Username: bob
[config] env OSMOSNOTE_REPO_DIR: /home/bob/osmosdata
[config] env OSMOSNOTE_SERVER_PORT: 6683
[config] Creating dir: /home/bob/osmosdata
[config] Error creating repo directory: /home/bob/osmosdata Error: EACCES: permission denied, mkdir '/home/bob/osmosdata'
at Object.mkdirSync (node:fs:1334:3)
at Object.module2.exports.makeDirSync (/usr/local/bin/osmosnote/dist/main.js:39655:18)
at ensureRepoConfig (/usr/local/bin/osmosnote/dist/main.js:56910:31)
at async run (/usr/local/bin/osmosnote/dist/main.js:57931:3) {
errno: -13,
syscall: 'mkdir',
code: 'EACCES',
path: '/home/bob/osmosdata'
}
but i found the home/bob/osmosdata directory creation succeeded
Thanks for reporting this. After some initial research, I think this has become a bigger problem than I initially expected. Writing down some notes here for further investigation. Any help is appreciated.
Goals
- We want to mount the host filesystem into the container without changing host directory's owner.
- We want to grant container user write permission to that host directory
- The container should use the host user's id and group_id to modify the host filesystem
- We do not know the host user's id and group_id during
docker build. User must be able to specify them indocker runcommand. - Avoid docker-compose (ideally)
Related issues
- node-alpine image creates a user called "node", using the same id and group_id (1000:1000) as the host user
- Docker sets the owner of all mounted volumes as
root.
Workaround
Mount the host directory with root user for now. This means /home/bob/osmosdata on the host machine will be owned by root.
docker run -p 6684:6684 -e "OSMOSNOTE_REPO_DIR=/home/bob/osmosdata" -v /home/bob/osmosdata:/data osmoscraft/osmosnote
References
https://github.com/moby/moby/issues/2259 https://github.com/nodejs/docker-node/blob/main/docs/BestPractices.md#non-root-user https://jtreminio.com/blog/running-docker-containers-as-current-host-user/ https://faun.pub/set-current-host-user-for-docker-container-4e521cef9ffc