FROM alpine WORKDIR /root ### install required dependencies (perl not required!) RUN apk add bash libc-dev gcc make patch git curl ### download plenvsetup RUN curl -sL https://is.gd/plenvsetup > plenvsetup && chmod +x plenvsetup ### use plenvsetup on bash ENV SHELL=/bin/bash RUN bash plenvsetup ### install perl-5.30.0 with plenv RUN .plenv/bin/plenv install 5.30.0 RUN .plenv/bin/plenv global 5.30.0 RUN .plenv/bin/plenv rehash CMD /bin/bash
Then, you can build the Dockerfile, and run perl-5.30.0 within the container.
$ docker build -t ytnobody/plenvsetup . Sending build context to Docker daemon 2.048kB Step 1/10 : FROM alpine ---> cc0abc535e36 Step 2/10 : WORKDIR /root ---> Using cache ---> 5a63e9728352 Step 3/10 : RUN apk add bash libc-dev gcc make patch git curl ---> Using cache ---> 0fed43f11239 Step 4/10 : RUN curl -sL https://is.gd/plenvsetup > plenvsetup && chmod +x plenvsetup ---> Using cache ---> 2b8ce1c5f1fa Step 5/10 : ENV SHELL=/bin/bash ---> Using cache ---> 6f661e8cf191 Step 6/10 : RUN bash plenvsetup ---> Using cache ---> 24f2c6c713f0 Step 7/10 : RUN .plenv/bin/plenv install 5.30.0 ---> Running in 86f08ede1c38 ---> Downloading https://cpan.metacpan.org/authors/id/X/XS/XSAWYERX/perl-5.30.0.tar.gz ---> Unpacking /root/.plenv/cache/perl-5.30.0.tar.gz ---> Applying Devel::PatchPerl 1.80 (patchperl-extracted 0.0.1) ---> Building perl 5.30.0 ---> See /root/.plenv/build/1578556140.1/build.log for progress ---> ./Configure -des -Dprefix=/root/.plenv/versions/5.30.0 -Dscriptdir=/root/.plenv/versions/5.30.0/bin ---> make ---> make install ---> Successfully installed perl 5.30.0 Removing intermediate container 86f08ede1c38 ---> 73c2b52fa025 Step 8/10 : RUN .plenv/bin/plenv global 5.30.0 ---> Running in 439f41b196dd Removing intermediate container 439f41b196dd ---> 8e819e1afd8c Step 9/10 : RUN .plenv/bin/plenv rehash ---> Running in 31d3278595ce Removing intermediate container 31d3278595ce ---> 28e28a126931 Step 10/10 : CMD /bin/bash ---> Running in c67a1e299db0 Removing intermediate container c67a1e299db0 ---> 3ceac81cf2f4 Successfully built 3ceac81cf2f4 Successfully tagged ytnobody/plenvsetup:latest $ docker run --rm -it ytnobody/plenvsetup bash-5.0# perl -v This is perl 5, version 30, subversion 0 (v5.30.0) built for x86\_64-linux (with 1 registered patch, see perl -V for more detail) Copyright 1987-2019, Larry Wall Perl may be copied only under the terms of either the Artistic License or the GNU General Public License, which may be found in the Perl 5 source kit. Complete documentation for Perl, including FAQ lists, should be found on this system using "man perl" or "perldoc perl". If you have access to the Internet, point your browser at http://www.perl.org/, the Perl Home Page.
$ perl -Ilib t/12_shell.t ok 1 - process sleep 3 sec. Then print "done" is work ok 2 - process sleep 3 sec. Then print "done" exit code is 0 ok 3 - process sleep 3 sec. Then print "done" is not work ok 4 ok 5 - process sleep 3 sec. Then print "done" STDERR like (?^:\A\z) 1..5
$ perl -Ilib t/13_shell-with-test_proc.t Type of arg 2 to Test::Proc::test_proc must be sub {} (not constant item) at t/13_shell-with-test_proc.t line 5, near "'bash ./hoge.sh';" Execution of t/13_shell-with-test_proc.t aborted due to compilation errors.
$ perl -Ilib t/13_shell-with-test_proc.t ok 1 - process my_work is work ok 2 - process my_work exit code is 0 ok 3 - process my_work is not work ok 4 ok 5 - process my_work STDERR like (?^:\A\z) 1..5