What news from AWS re:Invent last week will have the most impact on you?
Amazon Q, an AI chatbot for explaining how AWS works.
Super-fast S3 Express storage.
New Graviton 4 processor instances.
Emily Freeman leaving AWS.
I don't use AWS, so none of this will affect me.

Start Developing with Rocky Linux as a Docker Container

Rocky Linux has become a popular container image. So, why not start developing with it? Here is how to get started.
Nov 4th, 2023 6:00am by
Featued image for: Start Developing with Rocky Linux as a Docker Container
Feature Image by Martyn Cook from Pixabay.

I tend to default to Ubuntu as my go-to OS for Docker containers. Because I’ve been using Ubuntu for such a long time, it’s just second nature to me. That doesn’t mean, however, it’s the only operating system I use.

Case in point, Rocky Linux. Whenever I need a Red Hat Enterprise Linux-based OS, I opt for the distribution created by Gregory Kurtzer who originated CentOS. Back in 2021, Kurtzer made Rocky Linux available as a container image. Since then, the Rocky Linux Docker image has enjoyed over 10 million pulls from Docker Hub.

Clearly, Rocky Linux has become a popular container image. So, why not start developing with it? One thing to know is that the Rocky Linux container image has been stripped down to only the necessary tools for container deployment. In other words, this isn’t the same Rocky Linux you can download and use as a server OS.

Let me help you get started with this task. It’s not nearly as challenging as you might think.

What You Need

The only things you’ll need for this are an operating system that supports Docker and a user with sudo privileges. I’m going to demonstrate on Ubuntu Server 22.04, so if you’re using a non-Ubuntu distribution, you’ll need to alter the Docker installation commands as shown below.

Installing Docker

On the off-chance you haven’t already installed Docker on Ubuntu Linux, here’s how it’s done.

The first thing to be done is to download and install the official Docker GPG key with the command:

Next, we must add the Docker repository so it can be installed with apt-get. The command to add the repository is:

Install a few simple dependencies with the following command:

Update apt:

Install Docker CE with the following:

With Docker installed, you’ll need to add your user to the docker group, so you can manage Docker without having to use sudo (which can be a security issue). To add your user to the group, run the command:

Finally, log out and log back in so the changes take effect.

Pulling the Rocky Linux image

Before we can deploy the container, we must pull the Rocky Linux image with the command:

When the pull completes, verify it’s available with the command:

You should see something like this in the output:

Deploy and Access the Rocky Linux container

Next, we’ll deploy our container with the command:

Once the container has deployed, access it with the command:

You should now find yourself at the bash prompt of the Rocky Linux container. You’ll know if the prompt starts with root@.

Install a Web Server

Let’s install the Apache web server in our running container with the command:

Start the Apache daemon with the command:

Verify the web server is running with the command:

You should see the contents of the Apache welcome page (in text form) in the output that starts with:

Exit from the running container with the command:

What we’ll now do is create a new image from our running container. Instead of our image being a base Rocky Linux image, it will now include the Apache web server. Of course, before you exit the container, you could always install whatever you need that will be included in the new image.

To create the new image from the running container, you must first locate the ID of the running container with the command:

The ID will be a random string of characters.

Next, we create our new image with the docker commit command like so:

Where ID is the first four characters of the running Rocky Linux container. Of course, you can name your template whatever you like. Just make sure the name clearly indicates what the image is to be used for.

You can then verify the new image has been successfully created with the command:

The output of the above command should look something like this:

As you can see, our new template has been created and is ready to use. You could then deploy a container with that template image like so:

And that’s all there is to get started using Rocky Linux as a development image with Docker. You can now extend your efforts beyond Ubuntu Server as a base for your container deployments.

Group Created with Sketch.
TNS owner Insight Partners is an investor in: Docker.
THE NEW STACK UPDATE A newsletter digest of the week’s most important stories & analyses.