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
231 views
in Technique[技术] by (71.8m points)

docker - Missing perl command in Perl image

I'm sure this is an incredibly simple fix. I tried to build Docker image with Perl in it (plus some Perl) modules. However, when I go to run this, it says there is no /bin/perl. The question is:

Why did the Perl Docker Image not have Perl in it?

My Dockerfile below:

FROM perl:5.20

ENV PERL_MM_USE_DEFAULT 1
RUN cpan install Net::SSL inc:latest
RUN mkdir /ssc
COPY /ssc /ssc
RUN mkdir /tmp/ssc-bin-files;cp /ssc/bin/*.sh /tmp/ssc-bin-files;chmod a+rx /tmp/ssc-bin-files/*;cp /tmp/ssc-bin-files/* /ssc/bin
RUN chmod a+rx /ssc/bin/*.sh
ENTRYPOINT ["/ssc/bin/put-and-submit.sh"]

Jenkins Pipeline snippet:

    stage('Build, Tag and Push SSC Dockerfile'){
        tagAsTest = "${IMAGE_NAME}:test"
        REPO = "chq-ic2e-sprint-images-docker-local"
        println "Docker App Build"
        docker.build(tagAsTest,"-f Dockerfile .")
        sh 'docker image ls | grep rules-client'
    }
              
    stage('Set image tag to :approved'){
        hasReachedDockerComposeUp=false;
        REPO = "chq-ic2e-sprint-images-docker-local"
        sh "docker tag ${IMAGE_NAME}:test ${IMAGE_NAME}:approved"
        buildInfo = rtDocker.push("${IMAGE_NAME}:approved", REPO , buildInfo)
        server.publishBuildInfo buildInfo
    }

The Jenkins log below:

[Pipeline] sh
+ docker build -t chq-ic2e-sprint-images-docker-local.artifactory.swg-devops.com/ssc-cost-file-processor:test -f Dockerfile .
Sending build context to Docker daemon  39.42kB

Step 1/8 : FROM perl:5.20
 ---> bbe5a82c1dbe
Step 2/8 : ENV PERL_MM_USE_DEFAULT 1
 ---> Using cache
 ---> ca2769a89ab8
Step 3/8 : RUN cpan install Net::SSL inc:latest
 ---> Using cache
 ---> 1e53f0573131
Step 4/8 : RUN mkdir /ssc
 ---> Using cache
 ---> a324effec8ce
Step 5/8 : COPY /ssc /ssc
 ---> d40bf34f8565
Step 6/8 : RUN mkdir /tmp/ssc-bin-files;cp /ssc/bin/*.sh /tmp/ssc-bin-files;chmod a+rx /tmp/ssc-bin-files/*;cp /tmp/ssc-bin-files/* /ssc/bin
 ---> Running in 02386f41174f
Removing intermediate container 02386f41174f
 ---> 4767a8e6f23a
Step 7/8 : RUN chmod a+rx /ssc/bin/*.sh
 ---> Running in 07646aa96048
Removing intermediate container 07646aa96048
 ---> f070fcd8a9e9
Step 8/8 : ENTRYPOINT ["/ssc/bin/put-and-submit.sh"]
 ---> Running in e6bab12f8f40
Removing intermediate container e6bab12f8f40
 ---> 1422df9d957b
Successfully built 1422df9d957b
Successfully tagged chq-ic2e-sprint-images-docker-local.artifactory.swg-devops.com/ssc-cost-file-processor:test
[Pipeline] sh
+ docker image ls
+ grep rules-client
chq-ic2e-sprint-images-docker-local.artifactory.swg-devops.com/rules-client                   approved            da334d1d8fae        2 days ago          22.5MB
chq-ic2e-sprint-images-docker-local.artifactory.swg-devops.com/rules-client                   test                da334d1d8fae        2 days ago          22.5MB

Script is being run via pipeline like this:

    stage('Run image'){
      sh '''
      docker run -i -v 
      --mount type=bind,source="$(pwd)/host-dirs,target=/host-dirs" 
      chq-ic2e-sprint-images-docker-local.artifactory.swg-devops.com/ssc-cost-file-processor:approved
      sh
      '''
    }

or from terminal like this:

#!/bin/bash
docker run -it 
 --mount type=bind,source="$(pwd)/host-dirs,target=/host-dirs" 
 chq-ic2e-sprint-images-docker-local.artifactory.swg-devops.com/ssc-cost-file-processor:approved sh

question from:https://stackoverflow.com/questions/65915025/missing-perl-command-in-perl-image

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

1 Reply

0 votes
by (71.8m points)

The perl binary is probably in /usr/local/bin/perl. You can check that in a shell in the running container.

host> docker exec -it your_container bash
container> which perl
/usr/local/bin/perl
container> exit

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

...