一、Docker 安装
这里我们是需要在 Linux 环境中安装 Docker,我本地使用的是 CentOS 7(官网建议 7 或 8),内核版本:3.10.0-1160.el7.x86_64,这些是强制的,内核一定要高于这个 3.10。
之后根据官网(Install Docker Engine on CentOS | Docker Documentation)来安装 Docker。
1. 更新一下 yum(这里需要时间,中间会有停顿,按 y 即可)
yum update
2. 卸载老版本 Docker(如果你之前安装过 Docker)
yum remove docker docker-common docker-selinux docker-engine
3. 安装 yum-utils(这里需要点时间)
yum-utils 中提供了 yum-config-manager 功能
yum install -y yum-utils
4. 设置 yum-config-manager 存储库的源
yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
5. 安装 Docker(这里需要时间,中间会有停顿,按 y 即可)
yum install docker-ce docker-ce-cli containerd.io
6. 安装完成验证
docker -v
这个是我本机安装的 Docker 版本:20.10.12。
7. 启动 Docker,并设置为开机自启
systemctl start docker
systemctl enable docker
二、HelloWorld
接着我们使用命令来运行一下 HelloWorld。
docker run hello-world
可以看到上面的提示:无法找到镜像:hello-world:last 在本地 ... 下载最新镜像为 helloworld:latest。
下载好之后下面的 Hello from Docker 就是执行。然后我们再来运行一下这个命令。
可以看到是没有问题的,自己去试一下。
这一讲就讲到这里,有问题可以联系我:QQ 2100363119,欢迎大家访问我的个人网站:https://www.lemon1234.com