本文参考官网地址:https://docs.docker.com/install/linux/docker-ce/centos/#os-requirements

1、卸载旧版本的docker

$ sudo yum remove docker \
docker-client \
docker-client-latest \
docker-common \
docker-latest \
docker-latest-logrotate \
docker-logrotate \
docker-selinux \
docker-engine-selinux \
docker-engine

2、安装依赖的工具

$ sudo yum install -y yum-utils \
device-mapper-persistent-data \
lvm2

yum-utils 提供了 yum-config-manager 功能,该功能后边会用到

device-mapper-persistent-data 和lvm2 是 devicemapper所需的依赖,devicemapper可以理解为一种docker用来存放容器和镜像的技术。

3、添加docker yum源,这时用到了 yum-config-manager

$ sudo yum-config-manager \
--add-repo \
https://download.docker.com/linux/centos/docker-ce.repo

4、开启刚才下载的yum源

$ sudo yum-config-manager --enable docker-ce-edge
$ sudo yum-config-manager --enable docker-ce-test

第三步下载下来的repo中已经包含了edge 和 test 仓库,但是默认是关闭的,所以需要我们手动开启,我们也可以用下边的命令来关闭它们

$ sudo yum-config-manager --disable docker-ce-edge

5、安装docker

你可以通过以下命令安装最新版的docker:

$ sudo yum install docker-ce

也可以挑选一个特定的版本:

先列出所有可选版本

[root@MiWiFi-R3L-srv proc]# yum list docker-ce --showduplicates | sort -r

Repodata is over  weeks old. Install yum-cron? Or run: yum makecache fast
* updates: mirrors..com
Loaded plugins: fastestmirror
Installed Packages
* extras: mirrors.cn99.com
docker-ce.x86_64 17.12..ce-.el7.centos docker-ce-stable
docker-ce.x86_64 17.09.1.ce-.el7.centos docker-ce-stable
docker-ce.x86_64 17.09..ce-.el7.centos installed
docker-ce.x86_64 17.09..ce-.el7.centos docker-ce-stable
docker-ce.x86_64 17.06..ce-.el7.centos docker-ce-stable
docker-ce.x86_64 17.06..ce-.el7.centos docker-ce-stable
docker-ce.x86_64 17.06..ce-.el7.centos docker-ce-stable
docker-ce.x86_64 17.03..ce-.el7.centos docker-ce-stable
docker-ce.x86_64 17.03..ce-.el7.centos docker-ce-stable
docker-ce.x86_64 17.03..ce-.el7.centos docker-ce-stable

如上文,已经列出了可用版本,我们选择所需要的版本,列表中第二列是版本号,第三列是package名

这里需要拼一下软件名,使用图中标红位置的字符串“docker-ce”和“17.09.1.ce”,再加上一个“-”,即可拼成。

比如我们要装17.09.1版的,那么软件名就是docker-ce-17.09.1.ce

官网原文(嘟嘟嘟一堆,又是可以使用全名,又是至少要到什么位置……不看也罢):

The contents of the list depend upon which repositories are enabled, and are specific to your version of
CentOS (indicated by the .el7 suffix on the version, in this example). Choose a specific version to install.
The second column is the version string. You can use the entire version string, but you need to include at least to the first hyphen.
The third column is the repository name, which indicates which repository the package is from and by extension its stability level.
To install a specific version, append the version string to the package name and separate them by a hyphen (-).
$ sudo yum install <你刚才拼出来的名称>

6、开启docker守护线程(服务端)

$ sudo systemctl start docker

7、跑个image试一下

$ sudo docker run hello-world

最新文章

  1. ps 实例部分
  2. fmdb 数据库的基本操作
  3. sshfs 实现普通用户可读写
  4. 7.在AngularJS视图中实现指令
  5. &lt;script&gt;标签应该放到&lt;/body&gt;标签之前
  6. postgresql 分区表
  7. Watch​Kit Learning Resources
  8. 什么是hibernate?
  9. linux 查看当前所在目录的全路径
  10. C语言统计运行时间
  11. ES6中var/let/const的区别
  12. 微信x5内核很鸡贼啊
  13. DBUtils--数据库连接池
  14. mui.init方法配置
  15. 【Hadoop学习之十三】MapReduce案例分析五-ItemCF
  16. 启动android monitor报错解决办法
  17. pgm1
  18. freemarker 宏嵌套nested 的使用
  19. kubernetes1.9管中窥豹-CRD概念、使用场景及实例
  20. 【canvas系列】用canvas实现一个colorpicker(类似PS的颜色选择器)

热门文章

  1. [转]mysql 一个表两列的值交换
  2. 也给我的E420拆机清清灰尘
  3. SQL Server:使用 PIVOT 行转列和 UNPIVOT 列转行
  4. go语言之进阶篇通过map生成json
  5. 别再为了this发愁了:JS中的this机制
  6. tensoflow数据读取
  7. Excel长数字防止转换为科学计数法
  8. hadoop hue切换中文版
  9. ngularJs项目实战!05: 不同controller作用域之间通信的方式
  10. OSX下安装VMware虚拟机, 加载kali系统