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 creating repo directory, but directory creation succeeded #6

Open
hjb2722404 opened this issue Oct 29, 2021 · 1 comment
Open
Assignees
Labels
bug Something isn't working documentation Improvements or additions to documentation help wanted Extra attention is needed

Comments

@hjb2722404
Copy link

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

@chuanqisun chuanqisun self-assigned this Nov 9, 2021
@chuanqisun chuanqisun added bug Something isn't working documentation Improvements or additions to documentation help wanted Extra attention is needed labels Nov 9, 2021
@chuanqisun
Copy link
Contributor

chuanqisun commented Nov 9, 2021

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

  1. We want to mount the host filesystem into the container without changing host directory's owner.
  2. We want to grant container user write permission to that host directory
  3. The container should use the host user's id and group_id to modify the host filesystem
  4. We do not know the host user's id and group_id during docker build. User must be able to specify them in docker run command.
  5. Avoid docker-compose (ideally)

Related issues

  1. node-alpine image creates a user called "node", using the same id and group_id (1000:1000) as the host user
  2. 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

moby/moby#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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working documentation Improvements or additions to documentation help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants