CentOS 7 安装 Docker
- 环境说明
 - 安装步骤
 - 阿里云镜像加速
 
环境说明
我们使用的是 CentOS 7 (64-bit)
Docker 运行在 CentOS 7 上,要求系统为 64 位、系统内核版本为 3.10 以上。
查看自己的内核:
用于打印当前系统相关信息(内核版本号、硬件架构、主机名称和操作系统类型 等)。
uname -r查看版本信息:
cat /etc/os-release安装步骤
官网安装参考手册:https://docs.docker.com/engine/install/centos/
- yum 安装 gcc 相关环境(需要确保虚拟机可以上外网 )
 
yum -y install gcc
yum -y install gcc-c++- 卸载旧版本
 
sudo yum remove docker \
                  docker-client \
                  docker-client-latest \
                  docker-common \
                  docker-latest \
                  docker-latest-logrotate \
                  docker-logrotate \
                  docker-engine- 安装需要的软件包
 
sudo yum install -y yum-utils- 设置镜像仓库
 
官网(国外):
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- 更新 yum 软件包索引
 
yum makecache fast- 安装 Docker CE
 
yum install docker-ce docker-ce-cli containerd.io- 启动 Docker
 
systemctl start docker至此,已经安装完
- 查看版本
 
docker version- 查看安装的镜像
 
docker images- 测试运行 hello
 
docker run hello-world卸载 docker
systemctl stop docker
yum -y remove docker-ce docker-ce-cli containerd.io
rm -rf /var/lib/docker阿里云镜像加速
介绍:https://www.aliyun.com/product/acr
查看自己的镜像加速器并配置

sudo mkdir -p /etc/docker
sudo tee /etc/docker/daemon.json <<-'EOF'
{
  "registry-mirrors": ["https://cbl6xdl3.mirror.aliyuncs.com"]
}
EOF
sudo systemctl daemon-reload
sudo systemctl restart docker您可以通过修改 daemon 配置文件/etc/docker/daemon.json 来使用加速器
测试 HelloWorld
启动 hello-world
docker run hello-worldrun 干了什么?

    
评论 (0)