0

I have a docker container to work in. I now have to install module inside the container (npm i) but I get the error message checkPermissions Missing write access to ../node_moduleslTree path /node_modules.

I can't change the docker file. Is there any way to change the permissions of the folder inside docker (shell). Or maybe switch User?

Greetings

Ckappo
  • 607
  • 1
  • 9
  • 27
  • Do you have to install this module inside a running container, or do you have to do it while creating the container? – greenPadawan Jul 29 '19 at 06:52
  • the container is already created. I have to install it inside a running container – Ckappo Jul 29 '19 at 06:52
  • You can just connect to the container using bash and then perform all your operations. Use the following command docker exec -it bash – greenPadawan Jul 29 '19 at 06:54
  • try: `docker exec -it container_name -c 'chmod -R 777 /path/to/node_modules'` – Thanh Nguyen Van Jul 29 '19 at 06:54
  • I get `OCI Runtime exec failed... executable file not found in $PATH` when I run `docker exec -it container_name -c 'chmod -R 777 /path/to/node_modules'` – Ckappo Jul 29 '19 at 08:06
  • Similar question here: https://stackoverflow.com/questions/48001082/oci-runtime-exec-failed-exec-failed-executable-file-not-found-in-path – Vafa Jul 29 '19 at 09:41

1 Answers1

3

Well, there are more than one solution. First one is that you connect to existing docker container with following command

docker exec -it name_of_the_container bash

and apply correct permission for desired directory. Probably correct permission:

chmod +w directory

There is also another solution if you are building this container. You can create Dockerfile and in this Dockerfile you will manage permission of this directory before container comes online.

Hope it helps

golobitch
  • 1,466
  • 3
  • 19
  • 38
  • when I run the bash I got `OCI runtime exec failed... bash executable file not found in $PATH: unknown` When I run it with `/bin/shh` and then chmod +w I get `Operation not permitted` – Ckappo Jul 29 '19 at 08:05
  • I will need a little bit more info. Who is the owner of that directory? What is the name of your user? Have you tried with root privileges? You can always use other shell than /bin/bash. Have you tried with just bash? What about /bin/sh? – golobitch Jul 29 '19 at 08:07
  • I can not tell you 100% who is the owner. But my current user don't have write access. How can I change the user to root in a running container? Should I add --user flag to exec? – Ckappo Jul 29 '19 at 08:11
  • 3
    how can you not tell that? Just run ls -lah in parent directory and it will give you info about owner, about permissions, etc. To connect to docker container as root: `docker exec -ti -u root container_name shell_path` – golobitch Jul 29 '19 at 08:19
  • 1
    Try with `sh` instead of `bash`: `docker exec -it name_of_the_container sh` – Pierre B. Jul 29 '19 at 08:50
  • After fixing proxy configs, it is now working with root user and sh. Thx guys for the help – Ckappo Jul 29 '19 at 09:49