docker版本升级

今天为了使用docker-compose里的一些新功能,比如service配置项下各种子项,把一台调试机的的docker版本进行了升级。

操作系统是CentOS Linux release 7.2.1511 (Core), docker原来的版本是1.9.1,升级到最新版本1.13.1.

升级过程如下:

首相获取最新版本,打开https://get.docker.com/builds/页面,显示如下:

# To install, run the following commands as root:
curl -fsSLO https://get.docker.com/builds/Linux/x86_64/docker-1.13.1.tgz && tar --strip-components=1 -xvzf docker-1.13.1.tgz -C /usr/local/bin

# Then start docker in daemon mode:
/usr/local/bin/dockerd

按照提示,下载并解压了压缩包。不过由于个人癖好,我把新版docker放在了/usr/local/docker目录下。

接下来停止旧版本

systemctl stop docker

按照提示启动docker的,报错:

# /usr/local/docker/dockerd
INFO[0000] libcontainerd: new containerd process, pid: 43325
WARN[0000] containerd: low RLIMIT_NOFILE changing to max  current=1024 max=4096
ERRO[0001] devmapper: Udev sync is not supported. This will lead to data loss and unexpected behavior. Install a dynamic binary to use devicemapper or s
elect a different storage driver. For more information, see https://docs.docker.com/engine/reference/commandline/daemon/#daemon-storage-driver-option
ERRO[0001] [graphdriver] prior storage driver devicemapper failed: driver not supported
Error starting daemon: error initializing graphdriver: driver not supported

原因是新老版本不兼容,把老版本重命名:

#  mv /var/lib/docker /var/lib/docker.1.9.1

再次启动,成功。但不是daemon模式。

# /usr/local/docker/dockerd
INFO[0000] libcontainerd: new containerd process, pid: 43416
WARN[0000] containerd: low RLIMIT_NOFILE changing to max  current=1024 max=4096
WARN[0001] overlay: the backing xfs filesystem is formatted without d_type support, which leads to incorrect behavior. Reformat the filesystem with ftype=1 to enable d_type support. Running without d_type support will no longer be supported in Docker 1.16.
INFO[0001] Graph migration to content-addressability took 0.00 seconds
WARN[0001] mountpoint for pids not found
INFO[0001] Loading containers: start.
INFO[0001] Firewalld running: false
INFO[0001] Default bridge (docker0) is assigned with an IP address 172.17.0.0/16. Daemon option --bip can be used to set a preferred IP address
INFO[0001] Loading containers: done.
INFO[0001] Daemon has completed initialization
INFO[0001] Docker daemon                                 commit=092cba3 graphdriver=overlay version=1.13.1
INFO[0001] API listen on /var/run/docker.sock
^CINFO[0033] Processing signal 'interrupt'
INFO[0033] stopping containerd after receiving terminated


转入后台运行:

# /usr/local/docker/dockerd &
[1] 43704
[root@yinnut205 ~]# INFO[0000] libcontainerd: new containerd process, pid: 43716
WARN[0000] containerd: low RLIMIT_NOFILE changing to max  current=1024 max=4096
WARN[0001] overlay: the backing xfs filesystem is formatted without d_type support, which leads to incorrect behavior. Reformat the filesystem with ftype=1 to enable d_type support. Running without d_type support will no longer be supported in Docker 1.16.
INFO[0001] [graphdriver] using prior storage driver: overlay
INFO[0001] Graph migration to content-addressability took 0.00 seconds
WARN[0001] mountpoint for pids not found
INFO[0001] Loading containers: start.
INFO[0001] Firewalld running: false
INFO[0001] Default bridge (docker0) is assigned with an IP address 172.17.0.0/16. Daemon option --bip can be used to set a preferred IP address
INFO[0001] Loading containers: done.
INFO[0001] Daemon has completed initialization
INFO[0001] Docker daemon                                 commit=092cba3 graphdriver=overlay version=1.13.1
INFO[0001] API listen on /var/run/docker.sock

OK,运行起来了。可以认为是升级成功了。

但是实际上,因为新老版本不兼容,以前的镜像什么的都没有了,需要重新从仓库拉取。

如果生产环境实际要用,需要提前将本地的镜像都提交到仓库或者进行备份并恢复。

备份并恢复的方式如下:

备份: docker save > xxx.tar

恢复: docker load < xxx.tar

恢复后tag都丢失了,需要重新打tag

docker tag xxxx yyyyyy:zzz

有私有仓库且网络顺畅的话,还是提交仓库重新拉取吧。不然镜像多了确实很麻烦。


你可能感兴趣的:(Linux系统,docker,升级,备份,恢复)