CentOS7 安装 Docker

1. Docker安装

参考文档

# 1. 卸载旧版本docker
sudo yum remove docker \
                  docker-client \
                  docker-client-latest \
                  docker-common \
                  docker-latest \
                  docker-latest-logrotate \
                  docker-logrotate \
                  docker-engine
                 
# 2. 安装工具
sudo yum install -y yum-utils

# 3. 设置阿里云yum源仓库
yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo

# 4. 更新yum软件包索引
yum makecache fast

# 5. 安装docker
sudo yum install -y docker-ce docker-ce-cli containerd.io

# 6. 启动docker
systemctl start docker

# 7. 设置开机自启
systemctl enable docker

# 8. 查看docker版本
docker -v

2. 配置镜像加速

sudo mkdir -p /etc/docker

sudo tee /etc/docker/daemon.json <<-'EOF'
{
  "registry-mirrors": [
        "https://elastic.m.daocloud.io",
        "https://docker.m.daocloud.io",
        "https://gcr.m.daocloud.io",
        "https://ghcr.m.daocloud.io",
        "https://k8s-gcr.m.daocloud.io",
        "https://k8s.m.daocloud.io",
        "https://mcr.m.daocloud.io",
        "https://nvcr.m.daocloud.io",
        "https://quay.m.daocloud.io",
        "https://dockerpull.com",
        "https://dockerproxy.net"
      ],
  "log-driver": "json-file",
  "log-opts": {
    "max-size": "10m",
    "max-file": "3"
  }
}
EOF

sudo systemctl daemon-reload

sudo systemctl restart docker

3. 安装管理页面

docker run -d -p 8088:9000 --name portainer --restart=always -v /var/run/docker.sock:/var/run/docker.sock -v /home/portiner/data:/data portainer/portainer-ce:2.21.0

通过浏览器访问:ip:8088


Docker 开启远程访问

完成Docker安装