Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
255 views
in Technique[技术] by (71.8m points)

docker - Dockerfile permissions not taking effect

My goal is to have /ssc/bin/put-and-submit.sh to be executable. I looked at another question, but do not think it applies.

FROM perl:5.20

ENV PERL_MM_USE_DEFAULT 1
RUN cpan install Net::SSL inc:latest
RUN mkdir /ssc
COPY /ssc /ssc
RUN chmod a+rx /ssc/bin/*.sh
ENTRYPOINT ["/ssc/bin/put-and-submit.sh"]
 stat /ssc/bin/put-and-submit.sh
  File: '/ssc/bin/put-and-submit.sh'
  Size: 1892            Blocks: 8          IO Block: 4096   regular file
Device: 7ah/122d        Inode: 293302      Links: 1
Access: (0600/-rw-------)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2021-01-27 04:14:43.000000000 +0000
Modify: 2021-01-27 04:14:43.000000000 +0000
Change: 2021-01-27 04:52:44.700000000 +0000
 Birth: -

I read the question below, and believe that circumstance is when another layer is added, it overwrites the previous one. In my case, I start with a Perl image, add a few CPAN libraries, copy a few files and then ask it to change permissions.

Dockerfile "RUN chmod" not taking effect

question from:https://stackoverflow.com/questions/65914191/dockerfile-permissions-not-taking-effect

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

I remember I had this problem too and it basically only worked when I just replaced the default /usr/local/bin/docker-php-entrypoint WITHOUT firing the ENTRYPOINT command (to use a custom entrypoint script). So in your case you have to find out what the default entrypoint file is perl is using (must also be in /usr/local/bin) and maybe replace that. Sorry it's not the exact "right" solution but in my case it worked out fine and good enough.

So what I'm doing for example for my PHP-FPM containers is the following (note that ENTRYPOINT is commented out):

COPY docker-entrypoint.sh /usr/local/bin/docker-php-entrypoint
RUN chmod +x /usr/local/bin/docker-php-entrypoint
# ENTRYPOINT ["/usr/local/bin/docker-php-entrypoint"]

Just in case, my sh script looks like this (only starts supervisor):

#!/bin/sh
set -e

echo "Starting supervisor service"
exec supervisord -c /etc/supervisor/supervisord.conf

I hope this gets you somewhere mate, cheers


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...