rancher 2.X 升級 (單節點)
1. 停止當前運行的 rancher
docker stop <RANCHER_CONTAINER_ID>
2. 創建當前Rancher Server容器的數據卷容器,以便在升級Rancher Server中使用,命名爲rancher-data容器。
替換<RANCHER_CONTAINER_ID>爲第一步中的容器ID。
替換<RANCHER_CONTAINER_TAG>爲您當前正在運行的Rancher版本。
docker create --volumes-from <RANCHER_CONTAINER_ID> --name rancher-data rancher/rancher:<RANCHER_CONTAINER_TAG>
例如:
[root@iz2ze9vuhs4lymdt21hexxz ~]# docker create --volumes-from 33e6bc256e5f --name rancher-data rancher/rancher:latest
7ae84c1ecb727e124d030509b2c26c313a7c9af40986a96b045bb45381e03756
3. 創建rancher-data數據卷容器的備份容器
如果升級失敗,可以通過此備份還原Rancher Server,容器命名:rancher-data-snapshot-<CURRENT_VERSION>.
替換<RANCHER_CONTAINER_ID>爲第二部中的容器ID。
替換<CURRENT_VERSION>爲當前安裝的Rancher版本的標記。
替換<RANCHER_CONTAINER_TAG>爲當前正在運行的Rancher版本。
該步驟可以忽略,只爲做一個快照以防止意外進行數據恢復。
docker create --volumes-from <RANCHER_CONTAINER_ID> --name rancher-data-snapshot-<CURRENT_VERSION> rancher/rancher:<RANCHER_CONTAINER_TAG>
例如:
[root@iz2ze9vuhs4lymdt21hexxz ~]# docker create --volumes-from 7ae84c1ecb72 --name rancher-data-snapshot-2.2.3 rancher/rancher:latest
8c8274948b15be24a1655482d144c23b30b2a2e7ac83bd75bc1d85d0bd20373f
4. 拉取Rancher的最新鏡像。
docker pull rancher/rancher:stable (或者rancher/rancher:latest)
5. 通過rancher-data數據卷容器啓動新的Rancher Server容器。
docker run -d --volumes-from rancher-data --restart=unless-stopped -p 80:80 -p 443:443 rancher/rancher:latest (或者rancher/rancher:stable)