Docker 安装rancher,官网为什么没有将vloume显式挂载映射出来?

# docker inspect rancher|grep  -C 5 Source
        },
        "Mounts": [
            {
                "Type": "volume",
                "Name": "3c16d29b1cae0c020e97cadeec81d6ca8e759cbb516944bb6735a53ecb876a9e",
                "Source": "/var/lib/docker/volumes/3c16d29b1cae0c020e97cadeec81d6ca8e759cbb516944bb6735a53ecb876a9e/_data",
                "Destination": "/var/lib/rancher",
                "Driver": "local",
                "Mode": "",
                "RW": true,
                "Propagation": ""
            },
            {
                "Type": "volume",
                "Name": "e20016eaafd4eb8d7f2af8c483686b9dfb34ebb4dc355984d3a70d60df605734",
                "Source": "/var/lib/docker/volumes/e20016eaafd4eb8d7f2af8c483686b9dfb34ebb4dc355984d3a70d60df605734/_data",
                "Destination": "/var/log",
                "Driver": "local",
                "Mode": "",
                "RW": true,
                "Propagation": ""
            },
            {
                "Type": "volume",
                "Name": "d14f1abfdff20adad090b965f0572971d615f03fedcd22149cca4f9abda8161a",
                "Source": "/var/lib/docker/volumes/d14f1abfdff20adad090b965f0572971d615f03fedcd22149cca4f9abda8161a/_data",
                "Destination": "/var/lib/cni",
                "Driver": "local",
                "Mode": "",
                "RW": true,
                "Propagation": ""
            },
            {
                "Type": "volume",
                "Name": "fff023e9562c2923cf8018c89caf636ffc30723aa73f03be07ff7f60e45dee91",
                "Source": "/var/lib/docker/volumes/fff023e9562c2923cf8018c89caf636ffc30723aa73f03be07ff7f60e45dee91/_data",
                "Destination": "/var/lib/kubelet",
                "Driver": "local",
                "Mode": "",
                "RW": true,
                "Propagation": ""

  • /var/lib/rancher
  • /var/log
  • /var/lib/cni
  • /var/lib/kubelet

这四个目录在官网的安装手册中为什么没有显式的给挂载出来,这样话,一旦rancher-server被误操作删除的,那岂不是无法恢复了?

如果你是 docker run 启动的 rancher,rancher 的数据目录是 /var/lib/rancher ,只要映射这一个目录就行了

明白,映射/var/lib/ranher的话,如果是内网环境,/var/lib/ranher下带的镜像包必须copy进去,还是可以在rancher的容器外,直接用docker load 加载就可以?

把镜像的 tar 包 copy 到 容器内部或者映射到本地的目录都行

OK,看到你之前的回复了

root@ksd:~# mkdir -p /data/rancher/k3s/agent/images/
root@ksd:~# docker run --rm --entrypoint "" -v $(pwd):/output rancher/rancher:v2.9.0 cp /var/lib/rancher/k3s/agent/images/k3s-airgap-images.tar /output/k3s-airgap-images.tar
root@ksd:~# ls
docker.sh  k3s-airgap-images.tar  snap
root@ksd:~# cp k3s-airgap-images.tar /data/rancher/k3s/agent/images/
root@ksd:~# docker run -d --restart=unless-stopped --privileged \
    -p 10080:80 -p 10443:443  \
    -e CATTLE_SYSTEM_DEFAULT_REGISTRY=registry.cn-hangzhou.aliyuncs.com \
    -e CATTLE_BOOTSTRAP_PASSWORD=rancher \
    -v /data/rancher:/var/lib/rancher \
    registry.cn-hangzhou.aliyuncs.com/rancher/rancher:v2.9.0
8b62637c72cfb4b3704d5811f8e9bbd37bd05a93c9155465e776b5e0481f5465