Rocky Linux is a good alternative to CentOS 8, based on RHEL code. Thus, if you are planning to test it then you can create and install the Rocky Linux image in a Docker container using the commands given here.
Docker is a platform that allows running virtual containers with different pre-configured images available on the Docker hub. Although the user can create its own app image to use in a container, however, Docker’s repository is vast, thus he/she would have most of the applications there. In the same way, the official developers of Rocky Linux also provide their Linux operating system container image on the Docker Hub. Let’ see how to access the same.
Install Rocky Linux Docker Image
1. Setup Docker
The first thing you need to have on your Windows, macOS, or Linux is the Docker setup, so as per your operating system install the Docker Engine and then start with other steps given in this article.
2. Pull Rocky Linux Image
Now, using the Docker CLI tool, run the pull command that will fetch the required Rocky Linux image from the Docker Hub.
docker pull rockylinux/rockylinux
By default, it uses the latest tag, thus the image will be the latest available version of the OS.
3. Check the available docker images
Let’s see whether the downloaded image is on our system or not. For that run-
docker images
4. Create Rocky Linux Container
Finally, we have the image and now we can create as many containers running with Rocky Linux. Here is the command to create one.
docker run -it --name rocky -d rockylinux/rockylinux
In the above command:
--name rocky
is the name of the container we want to create.
rockylinux/rockylinux
is the name of the image we have downloaded
-d
is the option to run the container in the background.
To check what are the containers already running on your system, we can use:
docker ps
5. Connect to the container command line
Now, we have the Rocky Linux container running in the background, let’s connect to its command for issuing commands.
docker exec -it --user root rocky /bin/bash
Although we have mentioned the particular user in the above command, however, even if you haven’t, by default it will connect with using the root user only.
6. Set root password
If you want to set a root password for the Rocky Linux container then after connecting its command line using the above step, just type:
dnf install passwd passwd
Enter the new password two times and you are done.
Those who are interesting to manage Containers using a graphical user interface can see our article- How to install Kitematic GUI on Rocky Linux.
Also, see:
- How to install and setup Docker Container on Rocky Linux 8
- Install AlmaLinux 8 Image in Docker Container
- How to install Docker Container on Manjaro Linux