注:本文参考来源见docker安装。
因为之前装错了,所以导致docker的配置较乱,所以先删除docker中的容器
1.启动docker
$ systemctl start docker
2.查看所有容器
$ docker ps -a
3.删除所有容器
$ docker rm $(docker ps -a -q)
4.卸载已安装的docker
$ sudo apt-get remove docker-ce docker-engine docker.io
5.更新
$ sudo apt-get update
6.设置允许apt使用网络存储库
$ sudo apt-get install \
apt-transport-https \
ca-certificates \
curl \
software-properties-common
7.添加Docker的官方GPG密钥
$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
8.验证(这一步没理解是做什么,应该是测试是否配置正确?)
$ sudo apt-key fingerprint 0EBFCD88
pub 4096R/0EBFCD88 2017-02-22
Key fingerprint = 9DC8 5822 9FC7 DD38 854A E2D8 8D81 803C 0EBF CD88
uid Docker Release (CE deb) <docker@docker.com>
sub 4096R/F273FCD8 2017-02-22
9.查看系统类型
$ lsb_release -cs
10.查看自己的cpu
$ sudo uname --p
11.再次更新
$ sudo apt-get update
12.接下来就可以安装docker-ce了,有两种方法
12.1 安装最新版本(作者这里采用了这种办法)
$ sudo apt-get install docker-ce
12.2 安装指定版本
12.2.1 查看版本列表
$ apt-cache madison docker-ce
12.2.2 安装自己需要的版本("<VERSION>"在此处填写本本列表中对应的版本号)
$ sudo apt-get install docker-ce=<VERSION>
13.测试,验证是否正确安装
$ sudo docker run hello-world
出现以下内容则表示安装成功:
Hello from Docker!
This message shows that your installation appears to be working correctly.
To generate this message, Docker took the following steps:
1. The Docker client contacted the Docker daemon.
2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
(amd64)
3. The Docker daemon created a new container from that image which runs the
executable that produces the output you are currently reading.
4. The Docker daemon streamed that output to the Docker client, which sent it
to your terminal.
To try something more ambitious, you can run an Ubuntu container with:
$ docker run -it ubuntu bash
Share images, automate workflows, and more with a free Docker ID:
https://hub.docker.com/
For more examples and ideas, visit:
https://docs.docker.com/get-started/
到此,docker-ce版本算是安装完成,下一章开始写一些使用步骤。