Perl is a high-level, general-purpose, interpreted, dynamic programming language. The Perl language borrows features from other programming languages, including C, shell scripting (sh), AWK, and sed.
%%LOGO%%
Dockerfile in your Perl app projectFROM perl:5.20
COPY . /usr/src/myapp
WORKDIR /usr/src/myapp
CMD [ "perl", "./your-daemon-or-script.pl" ]
Then, build and run the Docker image:
$ docker build -t my-perl-app .
$ docker run -it --rm --name my-running-app my-perl-app
For many simple, single file projects, you may find it inconvenient to write a complete Dockerfile. In such cases, you can run a Perl script by using the Perl Docker image directly:
$ docker run -it --rm --name my-running-script -v "$PWD":/usr/src/myapp -w /usr/src/myapp perl:5.20 perl your-daemon-or-script.pl
perl:onbuild image for Perl projectsSuppose you have a project that uses Carton to manage Perl dependencies. You can create a perl:carton image that makes use of the ONBUILD instruction in its Dockerfile, like this:
FROM perl:5.26
RUN cpanm Carton \
&& mkdir -p /usr/src/app
WORKDIR /usr/src/app
ONBUILD COPY cpanfile* /usr/src/myapp
ONBUILD RUN carton install
ONBUILD COPY . /usr/src/app
Then, in your Carton project, you can now reduce your project's Dockerfile into a single line of FROM perl:carton, which may be enough to build a stand-alone image.