各版本安装
- 菜鸟教程
- 官方教程
第一种安装:yum
1、卸载旧版本
systemctl stop dockeryum -y remove docker-ce#较旧的 Docker 版本称为 docker 或 docker-engine 。#如果已安装这些程序,请卸载它们以及相关的依赖项。yum remove docker \docker-client \docker-client-latest \docker-common \docker-latest \docker-latest-logrotate \docker-logrotate \docker-enginerm -rf /var/lib/docker
2、安装 Docker Engine-Community
2.1、设置仓库
#安装所需的软件包。yum-utils 提供了 yum-config-manager ,并且 device mapper 存储驱动程序需要 device-mapper-persistent-data 和 lvm2。$ sudo yum install -y yum-utils device-mapper-persistent-data lvm2#官方仓库,速度可能较慢$ sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo#阿里云仓库,速度块$ sudo yum-config-manager --add-repo https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
2.2、安装
```bash安装最新版本的 Docker Engine-Community 和 containerd,或者转到下一步安装特定版本:
$ sudo yum install docker-ce docker-ce-cli containerd.io
1、列出并排序您存储库中可用的版本。此示例按版本号(从高到低)对结果进行排序。 $ yum list docker-ce —showduplicates | sort -r
docker-ce.x86_64 3:18.09.1-3.el7 docker-ce-stable docker-ce.x86_64 3:18.09.0-3.el7 docker-ce-stable docker-ce.x86_64 18.06.1.ce-3.el7 docker-ce-stable docker-ce.x86_64 18.06.0.ce-3.el7 docker-ce-stable
yum install -y docker-ce-18.09.1
yum install -y docker-ce-18.06.0.ce
2、通过其完整的软件包名称安装特定版本,该软件包名称是软件包名称(docker-ce)加上版本字符串(第二列),从第一个冒号(:)一直到第一个连字符,并用连字符(-)分隔。例如:docker-ce-18.09.1。
$ sudo yum install docker-ce-
<a name="fCSm4"></a>## 3、启动```bashsystemctl start docker#通过运行 hello-world 映像来验证是否正确安装了 Docker Engine-Community 。docker run hello-world
第二种安装:使用tar包安装
1、解压
tar -xvf docker-18.06.1-ce.tgzcp docker/* /usr/bin/dockerd &docker -v
2、加入systemctl管理
vim /usr/lib/systemd/system/docker.service
[Unit]Description=Docker Application Container EngineDocumentation=https://docs.docker.comAfter=network-online.target firewalld.serviceWants=network-online.target[Service]Type=notify# the default is not to use systemd for cgroups because the delegate issues still# exists and systemd currently does not support the cgroup feature set required# for containers run by dockerExecStart=/usr/bin/dockerdExecReload=/bin/kill -s HUP $MAINPID# Having non-zero Limit*s causes performance problems due to accounting overhead# in the kernel. We recommend using cgroups to do container-local accounting.LimitNOFILE=infinityLimitNPROC=infinityLimitCORE=infinity# Uncomment TasksMax if your systemd version supports it.# Only systemd 226 and above support this version.#TasksMax=infinityTimeoutStartSec=0# set delegate yes so that systemd does not reset the cgroups of docker containersDelegate=yes# kill only the docker process, not all processes in the cgroupKillMode=process# restart the docker process if it exits prematurely#Restart=on-failure#StartLimitBurst=3#StartLimitInterval=60s[Install]WantedBy=multi-user.target
3、启动
systemctl start dockersystemctl enable docker
