如果存在旧版本,则先卸载
最好先将镜像导出保存,以免升级后丢失或者无法使用
如有正在运行的容器,先停止
$ 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
原文地址:https://www.cnblogs.com/yanhai307/p/10719663.html
时间: 2024-10-02 19:29:33