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)