是2020年4月25日做的这件事, 至少当学英语了吧.
环境: 阿里云服务器
官网文档
Estimated reading time:* 10 minutes
To get started with Docker Engine on CentOS, make sure you meet the prerequisites, then install Docker.
开始安装之前, 确保先读读Prerequiresites
To install Docker Engine, you need a maintained version of CentOS 7. Archived versions aren’t supported or tested.
The
centos-extras
repository must be enabled. This repository is enabled by default, but if you have disabled it, you need to re-enable it.The
overlay2
storage driver is recommended.
你应该有一个维护版本为7的CentOS系统. 归档的老旧的版本不被支持或拿来测试. 需要确保系统的附加设备仓库可用, 必须的.
extras - 附加设备
maintained version - 维护版本
Older versions of Docker were called
docker
ordocker-engine
. If these are installed, uninstall them, along with associated dependencies.
新老版本名字不同, 要先删掉老版本.
$ sudo yum remove docker \
docker-client \
docker-client-latest \
docker-common \
docker-latest \
docker-latest-logrotate \
docker-logrotate \
docker-engine
It’s OK if
yum
reports that none of these packages are installed.The contents of
/var/lib/docker/
, including images, containers, volumes, and networks, are preserved. The Docker Engine package is now calleddocker-ce
.
这个路径下的内容, 包括…被保留下来了
现在引擎已经改名docker ce了, 别认错咯
Before you install Docker Engine for the first time on a new host machine, you need to set up the Docker repository. Afterward, you can install and update Docker from the repository.
第一次在一个新主机机器上安装, 要先安装Docker repository. 之后你可以安装或更新Docker, 从这个repo
Install the
yum-utils
package (which provides theyum-config-manager
utility) and set up the stable repository.
安装yum-utils包, 它提供了yum-配置管理工具, 然后安装稳定repo
$ sudo yum install -y yum-utils
$ sudo yum-config-manager \
--add-repo \
https://download.docker.com/linux/centos/docker-ce.repo
都成功了
Optional: Enable the nightly or test repositories.
These repositories are included in the
docker.repo
file above but are disabled by default. You can enable them alongside the stable repository. The following command enables the nightly repository.$ sudo yum-config-manager --enable docker-ce-nightly
To enable the test channel, run the following command:
$ sudo yum-config-manager --enable docker-ce-test
You can disable the nightly or test repository by running the
yum-config-manager
command with the--disable
flag. To re-enable it, use the--enable
flag. The following command disables the nightly repository.$ sudo yum-config-manager --disable docker-ce-nightly
Learn about nightly and test channels.
提供了其他可选项, 节约时间, 不搞这个了.
主菜来了
Install the latest version of Docker Engine and containerd, or go to the next step to install a specific version:
安装最新版引擎和容器, 或者去next step 安装指定版本. 不要怂, 当然最新版.
$ sudo yum install docker-ce docker-ce-cli containerd.io
Complete! 喜闻乐见
If prompted to accept the GPG key, verify that the fingerprint matches
060A 61C5 1B55 8A7F 742B 77AA C52F EB6B 621E 9F35
, and if so, accept it.
GPG?
GNU隐私卫士(GPG, GNU Privacy Guard)部分展示如何实现基于公开密钥和私有密钥的加密机制.
Got multiple Docker repositories?
If you have multiple Docker repositories enabled, installing or updating without specifying a version in the
yum install
oryum update
command always installs the highest possible version, which may not be appropriate for your stability needs.
multiple - 许多 多重
Docker is installed but not started. The
docker
group is created, but no users are added to the group.
安装完成, 但没启动. docker group 已经创建, 但是没有users被添加进来呢.
To install a specific version of Docker Engine, list the available versions in the repo, then select and install:
a. List and sort the versions available in your repo. This example sorts results by version number, highest to lowest, and is truncated:
$ 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
The list returned depends on which repositories are enabled, and is specific to your version of CentOS (indicated by the
.el7
suffix in this example).b. Install a specific version by its fully qualified package name, which is the package name (
docker-ce
) plus the version string (2nd column) starting at the first colon (:
), up to the first hyphen, separated by a hyphen (-
). For example,docker-ce-18.09.1
.$ sudo yum install docker-ce-
docker-ce-cli- containerd.io Docker is installed but not started. The
docker
group is created, but no users are added to the group.
整个2是个指定版本的类似操作
Start Docker
sudo systemctl start docker
Verify that Docker Engine is installed correctly by running the hello-world
image.
sudo docker run hello-world
This command downloads a test image and runs it in a container. When the container runs, it prints an informational message and exits.
Docker Engine is installed and running. You need to use sudo
to run Docker commands. Continue to Linux postinstall to allow non-privileged users to run Docker commands and for other optional configuration steps.
现在还只能sudo命令, 继续可以授权给其他users
To upgrade Docker Engine, download the newer package file and repeat the installation procedure, using yum -y upgrade
instead of yum -y install
, and pointing to the new file.
(未完, 先使用)