Skip to main content
Redhat Developers  Logo
  • Products

    Featured

    • Red Hat Enterprise Linux
      Red Hat Enterprise Linux Icon
    • Red Hat OpenShift AI
      Red Hat OpenShift AI
    • Red Hat Enterprise Linux AI
      Linux icon inside of a brain
    • Image mode for Red Hat Enterprise Linux
      RHEL image mode
    • Red Hat OpenShift
      Openshift icon
    • Red Hat Ansible Automation Platform
      Ansible icon
    • Red Hat Developer Hub
      Developer Hub
    • View All Red Hat Products
    • Linux

      • Red Hat Enterprise Linux
      • Image mode for Red Hat Enterprise Linux
      • Red Hat Universal Base Images (UBI)
    • Java runtimes & frameworks

      • JBoss Enterprise Application Platform
      • Red Hat build of OpenJDK
    • Kubernetes

      • Red Hat OpenShift
      • Microsoft Azure Red Hat OpenShift
      • Red Hat OpenShift Virtualization
      • Red Hat OpenShift Lightspeed
    • Integration & App Connectivity

      • Red Hat Build of Apache Camel
      • Red Hat Service Interconnect
      • Red Hat Connectivity Link
    • AI/ML

      • Red Hat OpenShift AI
      • Red Hat Enterprise Linux AI
    • Automation

      • Red Hat Ansible Automation Platform
      • Red Hat Ansible Lightspeed
    • Developer tools

      • Red Hat Trusted Software Supply Chain
      • Podman Desktop
      • Red Hat OpenShift Dev Spaces
    • Developer Sandbox

      Developer Sandbox
      Try Red Hat products and technologies without setup or configuration fees for 30 days with this shared Openshift and Kubernetes cluster.
    • Try at no cost
  • Technologies

    Featured

    • AI/ML
      AI/ML Icon
    • Linux
      Linux Icon
    • Kubernetes
      Cloud icon
    • Automation
      Automation Icon showing arrows moving in a circle around a gear
    • View All Technologies
    • Programming Languages & Frameworks

      • Java
      • Python
      • JavaScript
    • System Design & Architecture

      • Red Hat architecture and design patterns
      • Microservices
      • Event-Driven Architecture
      • Databases
    • Developer Productivity

      • Developer productivity
      • Developer Tools
      • GitOps
    • Secure Development & Architectures

      • Security
      • Secure coding
    • Platform Engineering

      • DevOps
      • DevSecOps
      • Ansible automation for applications and services
    • Automated Data Processing

      • AI/ML
      • Data Science
      • Apache Kafka on Kubernetes
      • View All Technologies
    • Start exploring in the Developer Sandbox for free

      sandbox graphic
      Try Red Hat's products and technologies without setup or configuration.
    • Try at no cost
  • Learn

    Featured

    • Kubernetes & Cloud Native
      Openshift icon
    • Linux
      Rhel icon
    • Automation
      Ansible cloud icon
    • Java
      Java icon
    • AI/ML
      AI/ML Icon
    • View All Learning Resources

    E-Books

    • GitOps Cookbook
    • Podman in Action
    • Kubernetes Operators
    • The Path to GitOps
    • View All E-books

    Cheat Sheets

    • Linux Commands
    • Bash Commands
    • Git
    • systemd Commands
    • View All Cheat Sheets

    Documentation

    • API Catalog
    • Product Documentation
    • Legacy Documentation
    • Red Hat Learning

      Learning image
      Boost your technical skills to expert-level with the help of interactive lessons offered by various Red Hat Learning programs.
    • Explore Red Hat Learning
  • Developer Sandbox

    Developer Sandbox

    • Access Red Hat’s products and technologies without setup or configuration, and start developing quicker than ever before with our new, no-cost sandbox environments.
    • Explore Developer Sandbox

    Featured Developer Sandbox activities

    • Get started with your Developer Sandbox
    • OpenShift virtualization and application modernization using the Developer Sandbox
    • Explore all Developer Sandbox activities

    Ready to start developing apps?

    • Try at no cost
  • Blog
  • Events
  • Videos

Deploying PSGI Applications using RHSCL Docker Containers

November 18, 2015
Petr Pisar
Related topics:
ContainersLinux
Related products:
Red Hat Enterprise Linux

Share:

    Red Hat Software Collections (RHSCL) 2.0 brings Perl 5.20 as a Docker image. This allows you to deploy Perl applications easily.

    The basic idea is to combine your application code from Git tree and Red Hat's rhscl/perl-520-rhel7 base image into an application image that will run your application in mod_perl environment. Your application can either be a simple Common Gateway Interface (CGI) script or a full-fledged Perl Web Server Gateway Interface (PSGI) application.

    Following this step-by-step procedure will show you how to deploy a simple pastebin-like web service implemented as a PSGI application.

    The Base Image

    First we install docker package and start the docker service:

    # yum install docker
    # systemctl start docker

    Then we download the rhscl/perl-520-rhel7 Docker image:

    # docker pull rhscl/perl-520-rhel7

    Now you can verify that the base image really contains Perl 5.20:

    # docker run --rm -ti rhscl/perl-520-rhel7 perl -v
    
    This is perl 5, version 20, subversion 1 (v5.20.1) built for x86_64-linux-thread-multi
    […]

    The Application Source

    Back to the application. We will create a simple pastebin-like application using Web::Paste::Simple Perl module. We will need git tool, so we will install it:

    # yum install git

    We will begin with an empty Git repository:

    $ mkdir application
    $ cd application
    $ git init-db .
    Initialized empty Git repository in /tmp/application/.git/

    Now we will write our application:

    $ cat >application.psgi
    use Web::Paste::Simple;
    Web::Paste::Simple->new()->app;
    ^D

    If you had locally installed some PSGI server, for example Plack from CPAN, you could test the application locally:

    $ plackup application.psgi
    HTTP::Server::PSGI: Accepting connections at http://0:5000/
    ^C

    But let's assume our code is correct and continue with building the application image.

    As I wrote, the application uses Web::Paste::Simple CPAN module. Thus we need to declare this dependency. We will use a cpanfile for that:

    $ cat >cpanfile
    requires 'Web::Paste::Simple';
    ^D

    If you haven't yet configured your Git identity, do it now:

    $ git config --global user.email "developer@example.com"
    $ git config --global user.name "Developer"

    And then commit the sources into Git tree:

    $ git add application.psgi cpanfile
    $ git commit -m 'Simple application'
    [master (root-commit) 78d64e4] Simple application
     2 files changed, 3 insertions(+)
     create mode 100644 application.psgi
     create mode 100644 cpanfile

    The Application Image

    Now we are ready to build our application image. We will use s2i tool for that. The tool is provided by source-to-image package, so install it:

    # yum install source-to-image

    The magic command to build an application from a base Docker image and a Git tree is:

    # s2i build file://$PWD rhscl/perl-520-rhel7 application
    I1109 15:39:58.995684 06268 sti.go:406] ---> Installing application source
    I1109 15:39:59.031843 06268 sti.go:406] ---> PSGI application found in
    ./application.psgi
    I1109 15:39:59.053222 06268 sti.go:406] ---> Installing cpanminus 1.7102 ...
    […]
    I1109 15:41:57.491068 06268 sti.go:406] <== Installed dependencies for ..
    Finishing.
    I1109 15:41:57.491118 06268 sti.go:406] 44 distributions installed

    The second argument is a URL to the Git tree with your application. We used current working directory in this example. But you can use any remote location. For example a repository on the GitHub. The third argument is base Docker image identifier. We used the Red Hat's Perl 5.20 RHSCL image. The last argument is a tag for the resulting application image.

    If you forget this incantation, don't worry. If you run the base image without specifying a command (docker run --rm -ti rhscl/perl-520-rhel7), you will get nice help. You can also see Using Red Hat Software Collections Container Images for more details.

    The Service

    As you can see, the application image was built successfully. And we can verify it in Docker images listing:

    # docker images
    REPOSITORY              TAG     IMAGE ID        CREATED         VIRTUAL SIZE
    application             latest  eed01e5e8b24    8 minutes ago   459.4 MB
    rhscl/perl-520-rhel7    latest  f3ed77ae8490    7 weeks ago     502.7 MB

    So we did it. Now we can run the application:

    # docker run --rm -ti application
    [Mon Nov 09 09:53:58.308695 2015] [so:warn] [pid 1] AH01574: module perl_module is already loaded, skipping
    AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 10.34.4.8. Set the 'ServerName' directive globally to suppress this message

    And the application will be available on the reported IP address and TCP port 8080. You can use docker's option -p to publish the container's port 8080 on different external port number.

    Finally, we can use a web browser to connect to the application:

    Empty Wep::Paste::Simple form

    And play with it:

    Submitted Wep::Paste::Simple form

    Last updated: July 7, 2025

    Recent Posts

    • Exploring Llama Stack with Python: Tool calling and agents

    • Enhance data security in OpenShift Data Foundation

    • AI meets containers: My first step into Podman AI Lab

    • Live migrating VMs with OpenShift Virtualization

    • Storage considerations for OpenShift Virtualization

    Red Hat Developers logo LinkedIn YouTube Twitter Facebook

    Products

    • Red Hat Enterprise Linux
    • Red Hat OpenShift
    • Red Hat Ansible Automation Platform

    Build

    • Developer Sandbox
    • Developer Tools
    • Interactive Tutorials
    • API Catalog

    Quicklinks

    • Learning Resources
    • E-books
    • Cheat Sheets
    • Blog
    • Events
    • Newsletter

    Communicate

    • About us
    • Contact sales
    • Find a partner
    • Report a website issue
    • Site Status Dashboard
    • Report a security problem

    RED HAT DEVELOPER

    Build here. Go anywhere.

    We serve the builders. The problem solvers who create careers with code.

    Join us if you’re a developer, software engineer, web designer, front-end designer, UX designer, computer scientist, architect, tester, product manager, project manager or team lead.

    Sign me up

    Red Hat legal and privacy links

    • About Red Hat
    • Jobs
    • Events
    • Locations
    • Contact Red Hat
    • Red Hat Blog
    • Inclusion at Red Hat
    • Cool Stuff Store
    • Red Hat Summit
    © 2025 Red Hat

    Red Hat legal and privacy links

    • Privacy statement
    • Terms of use
    • All policies and guidelines
    • Digital accessibility

    Report a website issue