Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Docker File: Chmod on Entrypoint Script

Tags:

Is there a reason I need to chmod +x on my entrypoint script? It didn't appear Redis was doing this in their dockerfile (https://github.com/docker-library/redis/blob/109323988b7663bceaf4a01c3353f8934dfc002e/2.8/Dockerfile) for their entrypoint script.

Dockerfile:

# Generic Docker Image for Running Node app from Git Repository FROM    node:0.10.33-slim ENV NODE_ENV production  # Add script to pull Node app from Git and run the app COPY docker-node-entrypoint.sh /entrypoint.sh RUN chmod +x /entrypoint.sh ENTRYPOINT ["/entrypoint.sh"]  EXPOSE  8080 CMD ["--help"] 
like image 930
AnDev123 Avatar asked Dec 03 '14 21:12

AnDev123


2 Answers

redis don't need to do it because their script already have exec flag:

~/redis/2.8$ ls -l docker-entrypoint.sh  -rwxrwxr-x 1 igor igor 109 Dec  3 23:52 docker-entrypoint.sh 

if you will do it for your docker-node-entrypoint.sh script you would not need chmod in Dockerfile too.

This is possible because the git core.fileMode option by default is true, so the executable bit of a file is honored.

like image 100
ISanych Avatar answered Sep 22 '22 13:09

ISanych


Docker will copy files into the container with the permissions of their source. If you strip the Linux executable bits somewhere in the chain of pushing to your code repo, or on your build host, then you'll need to add those execute permissions back. I've seen this issue most often reported by Windows users, who are downloading code to a filesystem that doesn't support the Linux permission bits. Hopefully we'll get a COPY --chmod solution soon that will eliminate the need for an extra layer.

like image 27
BMitch Avatar answered Sep 23 '22 13:09

BMitch