1、基本概念
Docker 包括三个基本概念
镜像( Image )
容器( Container )
仓库( Repository )
理解了这三个概念,就理解了 Docker 的整个生命周期。

2、Docker版本分类

Docker 分为 CE 和 EE 两大版本。CE 即社区版(免费,支持周期 7 个月),EE 即企业版,
强调安全,付费使用,支持周期 24 个月。
Docker CE 分为 stable, test, 和 nightly 三个更新频道。每六个月发布一个 stable 版本
(18.09, 19.03, 19.09...)。

3、CentOS 安装 Docker CE

警告:切勿在没有配置 Docker YUM 源的情况下直接使用 yum 命令安装 Docker.

准备工作

系统要求

Docker CE 支持 64 位版本 CentOS 7,并且要求内核版本不低于 3.10。 CentOS 7 满足最低
内核的要求,但由于内核版本比较低,部分功能(如 overlay2 存储层驱动)无法使用,并
且部分功能可能不太稳定。

卸载旧版本

旧版本的 Docker 称为 docker 或者 docker-engine ,使用以下命令卸载旧版本:

$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

使用官方安装脚本自动安装

curl -fsSL https://get.docker.com | bash -s docker --mirror Aliyun

使用 yum 安装

执行以下命令安装依赖包:

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

鉴于国内网络问题,强烈建议使用国内源

yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo

更新并安装Docker-ce

yum makecache fast
yum -y install docker-ce

开启Docker服务

systemctl enable docker
systemctl start docker

建立 docker 用户组

默认情况下, docker 命令会使用 Unix socket 与 Docker 引擎通讯。而只有 root 用户和
docker 组的用户才可以访问 Docker 引擎的 Unix socket。出于安全考虑,一般 Linux 系统
上不会直接使用 root 用户。因此,更好地做法是将需要使用 docker 的用户加入 docker
用户组。

建立 docker 组:

$ sudo groupadd docker

将当前用户加入 docker 组:

$ sudo usermod -aG docker $USER

注意:

# 官方软件源默认启用了最新的软件,您可以通过编辑软件源的方式获取各个版本的软件包。例如官方并没有将测试版本的软件源置为可用,你可以通过以下方式开启。同理可以开启各种测试版本等。

# vim /etc/yum.repos.d/docker-ce.repo

#   将 [docker-ce-test] 下方的 enabled=0 修改为 enabled=1

安装指定版本的Docker-CE:

查找Docker-CE的版本:

# yum list docker-ce.x86_64 --showduplicates | sort -r

#   Loading mirror speeds from cached hostfile

#   Loaded plugins: branch, fastestmirror, langpacks

#   docker-ce.x86_64            17.03.1.ce-1.el7.centos            docker-ce-stable

#   docker-ce.x86_64            17.03.1.ce-1.el7.centos            @docker-ce-stable

#   docker-ce.x86_64            17.03.0.ce-1.el7.centos            docker-ce-stable

#   Available Packages

安装指定版本的Docker-CE: (VERSION 例如上面的 17.03.0.ce.1-1.el7.centos)

# sudo yum -y install docker-ce-[VERSION]

安装校验

# docker version
Client:
Version: 18.06.1-ce
API version: 1.38
Go version: go1.10.3
Git commit: e68fc7a
Built: Tue Aug 21 17:23:03 2018
OS/Arch: linux/amd64
Experimental: false

Server:
Engine:
Version: 18.06.1-ce
API version: 1.38 (minimum version 1.12)
Go version: go1.10.3
Git commit: e68fc7a
Built: Tue Aug 21 17:25:29 2018
OS/Arch: linux/amd64
Experimental: false

测试 Docker 是否安装正确

# docker run hello-world

Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
d1725b59e92d: Pull complete
Digest: sha256:0add3ace90ecb4adbf7777e9aacf18357296e799f81cabc9fde470971e499788
Status: Downloaded newer image for hello-world:latest

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/

若能正常输出以上信息,则说明安装成功。

添加内核参数

默认配置下,如果在 CentOS 使用 Docker CE 看到下面的这些警告信息:

WARNING:    bridge-nf-call-iptables    is    disabled
WARNING: bridge-nf-call-ip6tables is disabled

请添加内核配置参数以启用这些功能。

$ sudo    tee    -a    /etc/sysctl.conf    <<-EOF
net.bridge.bridge-nf-call-ip6tables =
net.bridge.bridge-nf-call-iptables =
EOF

然后重新加载 sysctl.conf 即可

$ sudo sysctl -p

参考文档

https://docs.docker.com/engine/installation/linux/docker-ce/centos/    Docker 官方 CentOS 安装文档。

镜像加速

鉴于国内网络问题,后续拉取 Docker 镜像十分缓慢,强烈建议安装 Docker 之后配置 国内镜
像加速。

Ubuntu 16.04+、Debian 8+、CentOS 7

对于使用 systemd 的系统,请在 /etc/docker/daemon.json 中写入如下内容(如果文件不存
在请新建该文件)

# cat /etc/docker/daemon.json

{
"registry-mirrors": ["https://tlktz89e.mirror.aliyuncs.com"]    
}

注意,一定要保证该文件符合 json 规范,否则 Docker 将不能启动。

之后重新启动服务。

$sudo    systemctl    daemon-reload
$sudo systemctl restart docker

常用网址:

https://docs.docker.com/

https://account.aliyun.com/login/login.htm?oauth_callback=https%3A%2F%2Fcr.console.aliyun.com%2Fcn-qingdao%2Frepositories

http://www.bejson.com/

最新文章

  1. Python员工信息表练习
  2. pycharm配置字体问题
  3. 【BZOJ-1055】玩具取名 区间DP
  4. [zt]矩阵求导公式
  5. 20145218 《Java程序设计》课程总结
  6. [转] 浅谈Microsoft MVP
  7. Unity3D 游戏开发构架篇 ——角色类的设计与持久化
  8. Dispatcher及线程操作
  9. Win32下 Qt与Lua交互使用:配置Qt下Lua运行环境
  10. WordPress ‘get_allowed_mime_types’函数安全漏洞(2)
  11. UI事件之load
  12. three.js 源代码凝视(十)Math/Line3.js
  13. 淘宝联盟api调用笔记
  14. 破解linux虚拟机的密码
  15. BZOJ.2653.[国家集训队]middle(可持久化线段树 二分)
  16. CodeSmith和Powerdesigner的搭建和实例化操作 转载自黄聪同学
  17. const_cast的应用
  18. [试玩] FMXLinux (Firemonkey for Linux) Linux 桌面开发(第三方插件)
  19. 「七天自制PHP框架」应用:JSON生成器
  20. windows linux 下安装mysql 报1045 等错误

热门文章

  1. myeclipse集成svn客户端
  2. @Requestbody@ApiParam @PathVariable @RequestParam三者区别
  3. DbUtils(一) 结果集概览
  4. Dos窗口一闪而过,如何查看错误?
  5. Vue小贴士
  6. 018.Java类加载器
  7. Java基础知识——windows系统下安装JDK
  8. centos yum 安装mysql5.7 以及 默认root密码查看
  9. mysql5.6.31安装及配置
  10. ArcGIS for Android 10.1.1API 中文标注导致程序异常崩溃问题