0

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

Woodsman
  • 901
  • 21
  • 61

1 Answers1

1

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

Ray
  • 156
  • 1
  • 2
  • 14
  • so by commenting out the entryoint it actually worked? I guess I thought that was required, but I'm new to building docker files. – Woodsman Jan 27 '21 at 07:11
  • 1
    I copied my files to /tmp did the chmod on those files then copied the shell scripts where I wanted them. It works, but I didn't mark this has my answer because I don't like that I had to do that. – Woodsman Jan 27 '21 at 08:04
  • Yea so basically when you comment it out it still uses ENTRYPOINT but the default ENTRYPOINT (unless you fire a CMD instead of ENTRYPOINT). But yeah I don't exactly know why but as I said I just overwrite the default entrypoint script with mine and voila :) But indeed there must be a way – Ray Jan 27 '21 at 08:23
  • @Thanks Ray. Please see my other question too on the Perl container to. :) – Woodsman Jan 27 '21 at 08:27
  • Also, Docker sidenote, you can just use `CMD` (instead of `ENTRYPOINT`) to run a single command on startup of that service. I use my ENTRYPOINT script to run multiple service (such as Supervisor) and `CMD` can only run one (unless you use AND ;) ) – Ray Jan 27 '21 at 08:27
  • Also note, the ENTRYPINT line of course it DOES NOT have to be commented out, you can also just delete that line (obviously but just wanted to avoid possible confusion) – Ray Jan 27 '21 at 08:34