Skip to main content
Redhat Developers  Logo
  • Products

    Platforms

    • Red Hat Enterprise Linux
      Red Hat Enterprise Linux Icon
    • Red Hat AI
      Red Hat AI
    • Red Hat OpenShift
      Openshift icon
    • Red Hat Ansible Automation Platform
      Ansible icon
    • View All Red Hat Products

    Featured

    • Red Hat build of OpenJDK
    • Red Hat Developer Hub
    • Red Hat JBoss Enterprise Application Platform
    • Red Hat OpenShift Dev Spaces
    • Red Hat OpenShift Local
    • Red Hat 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
    • Automated Data Processing

      • AI/ML
      • Data Science
      • Apache Kafka on Kubernetes
    • Platform Engineering

      • DevOps
      • DevSecOps
      • Ansible automation for applications and services
    • Secure Development & Architectures

      • Security
      • Secure coding
  • Learn

    Featured

    • Kubernetes & Cloud Native
      Openshift icon
    • Linux
      Rhel icon
    • Automation
      Ansible cloud 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

    • Product Documentation
    • API Catalog
    • Legacy Documentation
  • 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

Dockerfiles now available for Red Hat Software Collections

 

December 3, 2014
Joe Orton
Related topics:
ContainersLinux
Related products:
Red Hat Enterprise Linux

Share:

    Shipping_containers_at_ClydeWe recently announced that we've made available a set of Dockerfiles for Red Hat Software Collections.  We are making these available since we think they may be useful to customers looking to build more complex application containers on top of RHEL and RHSCL. We don't intend the Dockerfiles to produce useful standalone images which you'll immediately put in production - the Docker images which these create are very simple containers which give you RHEL plus the basic set of packages from a particular RHSCL collection.

    There are two different ways to get your hands on the Dockerfiles:

    1. From the upstream source at github 
    2. From a new package, rhscl-dockerfiles, which we've shipped in the RHSCL channels - both for RHEL6 and RHEL7

    We have Dockerfiles available for each of the following collections in RHSCL 1.2: httpd24, mariadb55, mongodb24, mysql55, nginx16, nodejs010, perl516, php54, php55, postgresql92, python27, python33, ror40, ruby193, and ruby200.

    I'll walk through the second option here and demo the httpd24 collection.  I'm using the docker package from the RHEL Extras channel - RHEL customers can use this to access the base images for RHEL 6 and 7.  You'll need both the Extras channel and the RHSCL channel enabled to replicate this.  You may also need to configure the docker service to run in your environment, for example to change the networking configuration, but it should work out of the box.

    softwarecollections-logo-colorful

    First up we build a docker image; note I tagged the image (the "-t httpd24-el7" argument) so it's easy to refer to later.

    # yum install rhscl-dockerfiles
    ...
    Installed:
      rhscl-dockerfiles.noarch 0:1.2-4.el7
    
    Complete!
    # systemctl start docker
    # docker build -t httpd24-el7 /usr/share/rhscl-dockerfiles/rhel7/httpd24/
    Sending build context to Docker daemon 4.608 kB
    Sending build context to Docker daemon
    Step 0 : FROM rhel7
    ...
    Step 7 : EXPOSE 80
     ---> Running in 8fb43a750ad1
     ---> 5f337d2429f8
    Removing intermediate container 8fb43a750ad1
    Step 8 : EXPOSE 443
     ---> Running in 7d406717cb8c
     ---> 9e658e4a8417
    Removing intermediate container 7d406717cb8c
    Step 9 : ADD ./enablehttpd24.sh /etc/profile.d/
     ---> 4e19e92e1a90
    Removing intermediate container a6254b587d06
    Successfully built 4e19e92e1a90
    #

    In that transcript I've omitted the intermediate steps in the Dockerfile, which are mostly running "yum", but the last ones I've left in  The "EXPOSE" instruction exposes ports so they can be used from other contains.  The last instruction drops a bash login script into the system's "profile.d" directory.  This enables the SCL for a login shell.  Here's a demo, running "bash -l" to get a login shell

    # docker run -i -t httpd24-el7 bash -l
    bash-4.2# echo $X_SCLS
    httpd24
    bash-4.2# httpd -V
    Server version: Apache/2.4.6 (Red Hat)
    Server built: Jul 18 2014 06:22:07
    ...
     -D HTTPD_ROOT="/opt/rh/httpd24/root/etc/httpd"
    ...
    bash-4.2#

    That shows we have the RHSCL version of httpd.  If we did want to use that image... how to get it doing something useful?  Here I'll show the RHSCL httpd running using a filesystem mounted from the host, and mapping the port out:

    # mkdir /srv/www
    # echo 'Hello, Docker world.' > /srv/www/index.html
    # chcon -Rt svirt_sandbox_file_t /srv/www
    # docker run -d -v /srv/www:/opt/rh/httpd24/root/var/www/html -p 8080:80 httpd24-el7 scl enable httpd24 'httpd -DFOREGROUND'
    76e0705a9cdfc43389262e38460b16e8d7a31a2e7fba42cfb680bb5fe301f83a
    # curl http://localhost:8080/
    Hello, Docker world.
    #

    There is one trick above which might not be familiar to regular Docker users: I had to apply a special SELinux label, "svirt_sandbox_file_t", to the directory in the host system before it can be accessed from the container.  More details on that in the RHEL7 container guide. Otherwise, the "docker run" command does three things: it daemonizes (-d), and maps in the filesystem volume (-v) and port (-p).  The paths are appropriate to the RHSCL httpd24 collection, and httpd itself is run under "scl enable" so the SCL environment is set up correctly.

    That's it for a quick guide.  Let us know in the comments if you have use cases for  RHSCL Dockerfiles which you think we should address, or combinations of SCLs which you'd like to see shipping.

    Last updated: November 2, 2023

    Recent Posts

    • Kubernetes MCP server: AI-powered cluster management

    • Unlocking the power of OpenShift Service Mesh 3

    • Run DialoGPT-small on OpenShift AI for internal model testing

    • Skopeo: The unsung hero of Linux container-tools

    • Automate certificate management in OpenShift

    Red Hat Developers logo LinkedIn YouTube Twitter Facebook

    Platforms

    • Red Hat AI
    • Red Hat Enterprise Linux
    • Red Hat OpenShift
    • Red Hat Ansible Automation Platform
    • See all products

    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