跳到主要内容

第2章 Docker安装

1.国内源安装docker-ce

这里我们使用阿里源:

https://mirrors.aliyun.com/docker-ce/

操作步骤:

yum install -y yum-utils device-mapper-persistent-data lvm2
yum-config-manager --add-repo https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
sed -i 's+download.docker.com+mirrors.aliyun.com/docker-ce+' /etc/yum.repos.d/docker-ce.repo
yum makecache fast
yum install docker-ce
systemctl start docker

2.国内远镜像加速配置

加速地址:

https://status.1panel.top/status/docker

配置命令:

mkdir -p /etc/docker
cat > /etc/docker/daemon.json << 'EOF'
{
"registry-mirrors": [
"https://docker.1panel.live",
"https://proxy.1panel.live",
"https://docker.1panel.top"
]
}
EOF
systemctl daemon-reload
systemctl restart docker

3.运行第一个容器

运行一个Hello world

docker run alpine /bin/echo "Hello world"