The Docker image format and container runtime are now available in OpenShift / Kubernetes, which allows you import images from Docker Hub or any other external Docker registry.
OpenShift restrictions on containers
OpenShift Online being a public service puts high requirements on the security of user data. And for this particular reason, not every single container is allowed to run on the platform.
The general problem we see everyday is that containers are trying to run as root
. Is that a good idea? Not really, would you let the application running directly on the OS run as root? No! You would not and the same is true with containers. Applications should run as a regular use.
OpenShift does enforce this and because not all images are built in the sane way, you may run into problems with some containers. What's going to happen in that case? As you try to create the application you will see this notice:
<code>* WARNING: Image "<something>" runs as the 'root' user which may not be permitted by your cluster administrator</code>
In such a case you would need to build (if you are the owner) or rebuild (if you just want to use someone’s image) the image to not expect to be run as root.
Deploying the containers
To deploy custom containers, you need to use the terminal as it's not yet exposed in the web UI. You will use the oc
client tool with the new-app
command as you usually use for deploying stuff on OpenShift (oc new-app [image]~[source code]
).
<code>oc new-app centos/python-35-centos7~https://github.com/openshift/django-ex.git</code>
--> Found Docker image 59a9d28 (34 hours old) from Docker Hub for "centos/python-35-centos7"
Python 3.5
----------
Platform for building and running Python 3.5 applicationsTags: builder, python, python35, rh-python35
* An image stream will be created as "python-35-centos7:latest" that will track the source image
* A source build using source code from https://github.com/openshift/django-ex.git will be created
* The resulting image will be pushed to image stream "django-ex:latest"
* Every time "python-35-centos7:latest" changes a new build will be triggered
* This image will be deployed in deployment config "django-ex"
* Port 8080/tcp will be load balanced by service "django-ex"
* Other containers can access this service through the hostname "django-ex"
--> Creating resources with label app=django-ex ...
imagestream "python-35-centos7" created
imagestream "django-ex" created
buildconfig "django-ex" created
deploymentconfig "django-ex" created
service "django-ex" created
--> Success
Build scheduled, use 'oc logs -f bc/django-ex' to track its progress.
Run 'oc status' to view your app.
Once deployed, you need to expose the service provided by the container, in this case it would be:
<code>oc expose svc django-ex</code>
And check what your URL looks like:
<code>oc status</code>
Open the URL in your browser and you will be able to view your running application.
Voilà, you just deployed Python 3.5 on CentOS 7 using a pre-built container from Docker Hub.
About the author
Browse by channel
Automation
The latest on IT automation that spans tech, teams, and environments
Artificial intelligence
Explore the platforms and partners building a faster path for AI
Open hybrid cloud
Explore how we build a more flexible future with hybrid cloud
Security
Explore how we reduce risks across environments and technologies
Edge computing
Updates on the solutions that simplify infrastructure at the edge
Infrastructure
Stay up to date on the world’s leading enterprise Linux platform
Applications
The latest on our solutions to the toughest application challenges
Original shows
Entertaining stories from the makers and leaders in enterprise tech
Products
- Red Hat Enterprise Linux
- Red Hat OpenShift
- Red Hat Ansible Automation Platform
- Cloud services
- See all products
Tools
- Training and certification
- My account
- Developer resources
- Customer support
- Red Hat value calculator
- Red Hat Ecosystem Catalog
- Find a partner
Try, buy, & sell
Communicate
About Red Hat
We’re the world’s leading provider of enterprise open source solutions—including Linux, cloud, container, and Kubernetes. We deliver hardened solutions that make it easier for enterprises to work across platforms and environments, from the core datacenter to the network edge.
Select a language
Red Hat legal and privacy links
- About Red Hat
- Jobs
- Events
- Locations
- Contact Red Hat
- Red Hat Blog
- Diversity, equity, and inclusion
- Cool Stuff Store
- Red Hat Summit