How to migrate a CentOS 8 to Rocky Linux 8.10

Migrating a CentOS 8 Docker Container to Rocky Linux 8.10

With the end of life for CentOS Linux 8 and its shift towards CentOS Stream, many users are opting to switch to stable alternatives like Rocky Linux. If you're running a CentOS 8 Docker container and want to migrate it to Rocky Linux 8.10, this guide will walk you through the process.

In this post, we'll go over how to perform an in-place migration of a CentOS 8 Docker container to Rocky Linux 8.10. This process involves replacing CentOS packages with their Rocky Linux equivalents while retaining your current container's configurations and data.

Why Migrate from CentOS to Rocky Linux?

Rocky Linux is a community-driven project designed to be 100% bug-for-bug compatible with Red Hat Enterprise Linux (RHEL). After the CentOS Project announced its focus shift towards CentOS Stream, Rocky Linux became a preferred choice for users looking for a stable, production-grade Linux distribution compatible with RHEL.

Prerequisites

Before we begin, make sure:

  • You have a running CentOS 8 Docker container.
  • You can run administrative commands (e.g., sudo) inside your container.
  • Your Docker setup is properly configured.

Steps to Migrate CentOS 8 Docker Container to Rocky Linux 8.10

1. Back Up Your Container

Before making any changes, it's highly recommended to create a backup of your Docker container. This way, if something goes wrong during the migration, you can restore your container to its previous state.

Run the following command on your host machine (outside the container):

bash 复制代码
docker commit <container_id> backup-centos-container

Replace <container_id> with your actual container ID or container name.

This command saves the current state of your CentOS container as a new Docker image (backup-centos-container).

2. Update CentOS Packages (Optional)

It's a good practice to make sure that your CentOS system is fully up-to-date before starting the migration process. Inside the running container, execute:

bash 复制代码
sudo yum update -y

This will update all existing packages to their latest versions.

3. Install the Rocky Linux Migration Script

The Rocky Linux community provides an official migration script called migrate2rocky, which automates the process of switching from CentOS to Rocky Linux.

To download and install the script inside the container, run:

bash 复制代码
curl -O https://raw.githubusercontent.com/rocky-linux/rocky-tools/main/migrate2rocky/migrate2rocky.sh
chmod +x migrate2rocky.sh

4. Run the Migration Script

Once the script is downloaded and made executable, you can proceed with the migration by running the following command:

bash 复制代码
sudo ./migrate2rocky.sh -r

The -r flag stands for "reboot," and it will automatically reboot the container at the end of the migration process. This script will replace CentOS packages with Rocky Linux packages.

5. Verify the Migration

After the script finishes running, verify that your system is now running Rocky Linux by checking the /etc/os-release file:

bash 复制代码
cat /etc/os-release

You should see output indicating that the system is now Rocky Linux 8.10, similar to this:

bash 复制代码
NAME="Rocky Linux"
VERSION="8.10 (Green Obsidian)"
ID="rocky"
...

6. Restart the Docker Container

If the container doesn't automatically reboot, you can manually restart it from the host machine:

bash 复制代码
docker restart <container_id>

This ensures that all changes take effect after the migration.

7. Clean Up

Once the migration is complete, you might want to clean up old package metadata to free up space and avoid confusion in future package management operations:

bash 复制代码
sudo dnf clean all

Conclusion

By following these steps, you should have successfully migrated your CentOS 8 Docker container to Rocky Linux 8.10. This process replaces CentOS packages with Rocky Linux packages while preserving your container's data and configurations. Rocky Linux offers long-term support and stability, making it a suitable replacement for users who relied on CentOS.

If you're looking to move away from CentOS and need a RHEL-compatible distribution, Rocky Linux is an excellent choice for your Docker-based workloads.


Key Commands Summary:

  • Back up your container : docker commit <container_id> backup-centos-container

  • Update CentOS packages : sudo yum update -y

  • Download migration script :

    bash 复制代码
    curl -O https://raw.githubusercontent.com/rocky-linux/rocky-tools/main/migrate2rocky/migrate2rocky.sh
    chmod +x migrate2rocky.sh
  • Run migration script : sudo ./migrate2rocky.sh -r

  • Verify migration : cat /etc/os-release

  • Restart container : docker restart <container_id>

  • Clean up package metadata : sudo dnf clean all

相关推荐
likfishdn13 分钟前
Linux的文件与目录管理
linux·运维·服务器
chian-ocean32 分钟前
Linux 文件缓冲区:高效数据访问的幕后推手
linux·运维·服务器
加油=^_^=34 分钟前
【Linux】进程优先级 | 进程调度(三)
linux·运维·服务器
吃汤圆的抹香鲸1 小时前
GoLand 安装包 绿色版 Win,Mac,Linux 包含IntelliJ全家桶 专为Go语言设计的集成开发环境(IDE)
linux·windows·macos·go·intellij-idea·go1.19
追寻光1 小时前
Cannot find a valid baseurl for repo: base/7/x86_64
linux
元气满满的热码式1 小时前
Docker数据卷操作实战
linux·运维·docker·云原生·容器
陆沙1 小时前
deepseek-r1-centos-本地服务器配置方法
linux·服务器·centos
北京耐用通信1 小时前
航空装配自动化神器Ethercat转profient网关搭配机器人精准控制
运维·机器人·自动化
吃汤圆的抹香鲸2 小时前
Rider 安装包 绿色版 Win/Mac/Linux 适合.NET和游戏开发者使用 2025全栈开发终极指南:从零配置到企业级实战
linux·运维·windows·sql·游戏·macos·.net
sz66cm2 小时前
Linux基础 -- ARM 32 位架构动态注入代码技术文档
linux·arm开发·架构