![]() ![]() ![]() Judging from the error messages, the cause of failure is that npm tries to run subshells, but there is no entry in /etc/passwd for the UID and GID you provided. npm will then assume / as the home directory of that user, failing miserably because the user has no write permissions. v ~/tmp:/home/node -v $(pwd):/app -w /app npm install Then you mount the passwd file and a writeable directory of the current user: docker run -it -rm -u $(id -u):$(id -g) -v /tmp/fake-passwd:/etc/passwd \ First, you create a minimal passwd file for the current user on our host system: echo "node:x:$(id -u):$(id -g)::/home/node:/bin/bash" > /tmp/fake-passwd Finally, permission nirvanaĪ solution for the npm permission problem is to fake the passwd user entry and its home directory. This will install the dependencies with the current user as owner into node_modules. ![]() I don’t like having to create a passwd file and having to mount two additional things, but for my very specific use case - replacing a locally installed npm with npm running inside a container from an unmodified Node image - this seems like the best I can do. I wish Docker would provide a UID mapping between host and container volumes. There once was an issue for that, but the developers decided that the many workarounds would suffice. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |