Docker容器

CentOS安装Docker

本文主要是介绍CentOS安装Docker,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

移除以前docker相关包

sudo yum remove docker \
                  docker-client \
                  docker-client-latest \
                  docker-common \
                  docker-latest \
                  docker-latest-logrotate \
                  docker-logrotate \
                  docker-engine

添加yum源

sudo yum install -y yum-utils

sudo yum-config-manager \
--add-repo \
http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo

安装docker

sudo yum install -y docker-ce docker-ce-cli containerd.io

启动Docker

systemctl enable docker --now

配置docker下载镜像

sudo mkdir -p /etc/docker

sudo tee /etc/docker/daemon.json <<-'EOF'
{
  "registry-mirrors": ["https://82m9ar63.mirror.aliyuncs.com"],
  "exec-opts": ["native.cgroupdriver=systemd"],
  "log-driver": "json-file",
  "log-opts": {
    "max-size": "100m"
  },
  "storage-driver": "overlay2"
}
EOF

sudo systemctl daemon-reload

sudo systemctl restart docker

查看Docker是否运行

docker ps
这篇关于CentOS安装Docker的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!