我有什么理由需要在我的入口点脚本上 chmod +x 吗? Redis 似乎没有在他们的 dockerfile ( https://github.com/docker-library/redis/blob/109323988b7663bceaf4a01c3353f8934dfc002e/2.8/Dockerfile ) 中为其入口点脚本执行此操作。
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"]
最佳答案
redis 不需要这样做,因为他们的脚本已经有 exec 标志:
~/redis/2.8$ ls -l docker-entrypoint.sh
-rwxrwxr-x 1 igor igor 109 Dec 3 23:52 docker-entrypoint.sh
如果您要为您的 docker-node-entrypoint.sh 脚本执行此操作,您也不需要 Dockerfile 中的 chmod。
这是可能的,因为 git core.fileMode 选项默认为 true,所以文件的可执行位被尊重。
关于 docker 文件 : Chmod on Entrypoint Script,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27281965/