English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
Docker supports the following 64-bit CentOS versions:
CentOS 7
CentOS 8
Higher versions...
The installation command is as follows:
curl -fsSL https://get.docker.com | bash -s docker --mirror Aliyun
You can also use the one-click installation command of domestic daocloud:
curl -sSL https://get.daocloud.io/docker | sh
Older Docker versions are called docker or docker-engine. If these programs are already installed, please uninstall them and their related dependencies.
$ sudo yum remove docker \ docker-client \ docker-client-latest \ docker-common \ docker-latest \ docker-latest-logrotate \ docker-logrotate \ docker-engine
Before installing Docker Engine-Community on a new host for the first time, you need to set up the Docker repository. After that, you can install and update Docker from the repository.
Set up the repository
Install the required software packages. yum-utils provides yum-config-manager, and the device mapper storage driver requires device-mapper-persistent-data and 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 \ http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
$ sudo yum-config-manager \ --add-repo \ https://mirrors.tuna.tsinghua.edu.cn/docker-ce/linux/centos/docker-ce.repo
安装最新版本的 Docker Engine-Community 和 containerd,或者转到下一步安装特定版本:
$ sudo yum install docker-ce docker-ce-cli containerd.io
如果提示您接受 GPG 密钥,请选是。
有多个 Docker 仓库吗?
如果启用了多个 Docker 仓库,则在未在 yum install 或 yum update 命令中指定版本的情况下,进行的安装或更新将始终安装最高版本,这可能不适合您的稳定性需求。
Docker 安装完成后默认未启动。并且已经创建好 docker 用户组,但该用户组下没有用户。
要安装特定版本的 Docker Engine-Community,请在存储库中列出可用版本,然后选择并安装:
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
2、通过其完整的软件包名称安装特定版本,该软件包名称是软件包名称(docker-ce)加上版本字符串(第二列),从第一个冒号(:)一直到第一个连字符,并用连字符(-)分隔。例如:docker-ce-18.09.1。
$ sudo yum install docker-ce-<VERSION_STRING> docker-ce-cli-<VERSION_STRING> containerd.io
启动 Docker。
$ sudo systemctl start docker
通过运行 hello-world 映像来验证是否正确安装了 Docker Engine-Community 。
$ sudo docker run hello-world