linux系统docker版本升级或安装

Posted 万丈高楼平地起

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了linux系统docker版本升级或安装相关的知识,希望对你有一定的参考价值。

如果存在旧版本,则先卸载

最好先将镜像导出保存,以免升级后丢失或者无法使用

如有正在运行的容器,先停止

$ docker ps -q | xargs docker stop

关闭docker服务

$ systemctl stop docker.service
$ systemctl stop docker.socket

查看已经安装的docker

$ apt list | grep docker | grep installed
lxc-docker/now 1.9.1 amd64 [installed,local]
lxc-docker-1.9.1/now 1.9.1 amd64 [installed,local]

将其卸载掉

$ apt remove lxc-docker
$ apt remove lxc-docker-1.9.1

安装docker最新版本

确定已经安装curl命令,没有安装,则运行

$ apt install curl

运行命令安装

$ curl -fsSL https://get.docker.com/ | sh

安装完成后会有提醒

If you would like to use Docker as a non-root user, you should now consider
adding your user to the "docker" group with something like:

  sudo usermod -aG docker your-user

Remember that you will have to log out and back in for this to take effect!

WARNING: Adding a user to the "docker" group will grant the ability to run
         containers which can be used to obtain root privileges on the
         docker host.
         Refer to https://docs.docker.com/engine/security/security/#docker-daemon-attack-surface
         for more information

意思是:
当要以非root用户可以直接运行docker时,需要执行 sudo usermod -aG docker runoob 命令,然后重新登陆,否则会报错

重启docker服务

$ systemctl restart docker

查看版本

$ docker version 
Client:
 Version:           18.09.5
 API version:       1.39
 Go version:        go1.10.8
 Git commit:        e8ff056dbc
 Built:             Thu Apr 11 04:44:28 2019
 OS/Arch:           linux/amd64
 Experimental:      false

Server: Docker Engine - Community
 Engine:
  Version:          18.09.5
  API version:      1.39 (minimum version 1.12)
  Go version:       go1.10.8
  Git commit:       e8ff056
  Built:            Thu Apr 11 04:10:53 2019
  OS/Arch:          linux/amd64
  Experimental:     false

以上是关于linux系统docker版本升级或安装的主要内容,如果未能解决你的问题,请参考以下文章

linux系统内核升级实例

win10家庭版不带Hyper-V 怎样安装 docker

docker打包当前linux全部文件系统

linux centos下安装docker

linux使用shell脚本安装应用

Docker在Linux上 基本使用