Skaffold: Permission denied through skaffold

Created on 15 Jan 2019  路  14Comments  路  Source: GoogleContainerTools/skaffold

Hi, I'am using the version 0.20.0.

I have a strange behavior with the build stage. Here is my Dockerfile :

FROM node as build

COPY package.json package.json
RUN npm install
COPY . .
RUN npm run tsc

FROM node:alpine
COPY --from=build ./dist .
COPY package.json package.json
RUN npm install --prod
CMD ["node","index.js"]

When I build this Dockerfile using my local Docker, it works without any problem.
But, If I launch a skaffold dev the build fails with this error :

Step 5/10 : RUN npm run tsc
 ---> Running in 0c947ae2b542

> [email protected] tsc /
> ./node_modules/typescript/bin/tsc

sh: 1: ./node_modules/typescript/bin/tsc: Permission denied
npm ERR! code ELIFECYCLE
npm ERR! errno 126
npm ERR! [email protected] tsc: `./node_modules/typescript/bin/tsc`
npm ERR! Exit status 126
npm ERR!
npm ERR! Failed at the [email protected] tsc script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2019-01-15T13_37_07_099Z-debug.log

I have a permission denied through Skaffold that I don't have through my local docker.

The only workarround I have found is to add

 RUN chmod a+x ./node_modules/typescript/bin/tsc

Just before RUN npm run tsc

I don't understand why I have these different behaviors

Thank you

arebuild help wanted kinbug platforwindows prioritp1

Most helpful comment

I also encounter this issue, and write an article to re-produce it:
https://william-yeh.net/post/2019/06/docker-file-permissions/

All 14 comments

Hi @cabrinoob on which OS do you see this happening?

@dgageot : Oh sorry, I missed that : Windows 10

I have the feeling that it's related. Docker and file permissions has always been complicated. I'm gonna have to try and reproduce that on a windows machine.

I'm having the same problem on Windows 10

Same problem here on Windows 10...

I resolved my problem! I switched to Ubuntu :trollface:

same error here

or this probably going to be fix or should we try to find another solution?

unfortunately I don't think anyone on our team has been able to reproduce this one yet. any help digging into this one further and coming up with a fix would be greatly appreciated, we'd love to get it fixed but not sure we'll be able to prioritize this at the moment.

I also encounter this issue, and write an article to re-produce it:
https://william-yeh.net/post/2019/06/docker-file-permissions/

@cabrinoob Do you have a .dockerignore file where you're ignoring the node_modules directory? My guess is that you're copying the whole folder from windows into the image when running COPY . . after the npm install.

Docker for Windows is applying -rwxr-xr-x-- (read, write, executable) permissions to all files copied into the image. That's why the normal docker build . works on windows. I think Skaffold is creating its own context where all files only have -rw-rw-rw--- permissions.

So adding a .dockerignore should fix it.

@cedrickring : Hi, thank you. I cannot test your solution, because as I said earlier, I switched to linux. But I'll try to find someone here who is under Windows to do the test.

i had the same issue, the .dockerignore soloution fixed it for me

We are still planning to look into this: another workaround suggestion would be to try with useDockerCLI:true - that should use the docker cli instead of the docker client library - @gavinwilliams can you try if that works too?

I have a strange behavior with the build stage. Here is my Dockerfile :

My understanding is that your

COPY package.json package.json
RUN npm install
COPY . .
RUN npm run tsc

is a problem, as with the COPY . . command you OVERWRITE the just built containerized node_modules folder (and therefore remove X mode while transferring) with your host node_modules folder.

Try to

  1. be more explicit with copying, or
  2. remove host node_modules or
  3. add node_modules folder to the .dockerignore file

Let me know if that helps

Was this page helpful?
0 / 5 - 0 ratings