How to use Rocky Linux as a Docker container image

3 years ago 394

The creator of Rocky Linux has made the organisation disposable arsenic a Docker image. Jack Wallen shows you however to get it, deploy it and modify it.

Rocky Linux logo connected  upland  country   background

Illustration: Lisa Hornung/TechRepublic

Rocky Linux has emerged arsenic 1 of the apical contenders to regenerate CentOS for galore businesses. And for most, that server-centric Linux organisation volition beryllium deployed mostly connected bare metallic oregon arsenic a virtual machine. But there's different way to take, 1 that should person instrumentality developers rather pleased.

The developers of Rocky Linux person released a instrumentality image, truthful you tin commencement processing your containers based connected the caller Linux organisation from the originator of CentOS itself. The benefits of this see having a powerful, unafraid organisation for which to basal your containers. And due to the fact that this is an authoritative release, you tin beryllium definite it's been vetted and is harmless to use. 

SEE: Kubernetes: A cheat expanse (free PDF)  (TechRepublic)

Of course, similar astir container-specific images, the Rocky Linux representation has been stripped of immoderate of the services and apps that wouldn't beryllium indispensable for instrumentality deployment. That means you're getting a bare-bones organisation that you tin past usage to physique immoderate you need. That, combined with the accustomed Rocky Linux information and reliability marque this representation a premier campaigner for your instrumentality deployments.

Let's find retired however to adhd the Rocky Linux representation to your increasing Docker collection.

What you'll need

To marque this work, you'll request a instrumentality with the Docker motor installed and running. I'll show connected Ubuntu Server 20.04, but arsenic agelong arsenic you person Docker connected the machine, the level won't matter.

That's it. Let's get to work.

How to propulsion down the Rocky Linux image

Log into your instrumentality and unfastened a terminal window. To propulsion down the Rocky Linux image, contented the command:

docker propulsion rockylinux/rockylinux

After a moment, the representation volition beryllium saved to your section repository and is acceptable for use. You tin verify the representation is determination with the command:

docker images

You should spot rockylinux listed (Figure A).

Figure A

rocklinuxcontainera.jpg

The Rocky Linux representation has been saved and is acceptable to use.

How to make a instrumentality from the Rocky Linux image

While I person you, fto maine amusement you however to make a instrumentality from this image. We'll telephone the instrumentality rlinux and deploy it successful detached mode with the command:

docker tally -it --name rlinux -d rockylinux/rockylinux

Let's summation entree to the instrumentality truthful we tin enactment connected it with the command:

docker exec -it --user basal rlinux /bin/bash

From the instrumentality prompt, let's instal the Apache webserver with the command:

dnf instal httpd -y

Start the httpd daemon with the command:

httpd

Check to spot the server is moving with the command:

curl localhost

You should spot the output of the curl bid alert by.

Exit from the instrumentality with the exit command, and you're done. Your Rocky Linux instrumentality is up and running, and you've modified it by installing the Apache Web server. Now, let's accidental you privation to perpetrate the changes and make a caller representation based connected those changes. For that, you could contented the command:

sudo docker perpetrate ID rlinux-template

Where ID is the Container ID of the modified image. If you database retired your images, you should present spot rlinux-template included (Figure B).

Figure B

rockylinuxcontainerb.jpg

You present person a container, based connected Rocky Linux, which includes the Apache webserver.

You tin destruct the archetypal Rocky Linux instrumentality by archetypal locating the Container ID with the command:

docker ps -a

Stop the instrumentality with the command:

docker halt ID

Where ID is the archetypal 4 characters of the Container ID for your rlinux container. Remove the instrumentality with the command:

docker rm ID

Where ID is the Container ID for your rlinux container.

And that's each determination is to pulling down and utilizing the Rocky Linux Docker instrumentality image. Enjoy processing your containers with 1 of the champion server-centric distributions connected the market.

Developer Essentials Newsletter

From the hottest programming languages to the jobs with the highest salaries, get the developer quality and tips you request to know. Weekly

Sign up today

Also see

Read Entire Article