linux(centos与ubuntu)安装docker

首先确保系统更新

yum update  # centos
apt-get update   # ubuntu

centos安装docker

yum install -y yum-utils
yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
yum install -y docker-ce docker-ce-cli --allowerasing

ubuntu安装docker

for pkg in docker.io docker-doc docker-compose podman-docker containerd runc; do sudo apt-get remove $pkg; done
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) \stable"
sudo apt-get update
apt-get install docker-ce docker-ce-cli containerd.io

设置国内镜像源(ubuntu与centos一致)

执行如下命令:

		mkdir -p /etc/docker

		tee /etc/docker/daemon.json <<-'EOF'
{
	"registry-mirrors": [
		"http://hub-mirror.c.163.com",   # 163的源
		"https://docker.mirrors.ustc.edu.cn",   # 中科大
		"https://4u1h1l0e.mirror.aliyuncs.com",  # 阿里云的
		"https://registry.docker-cn.com"     # docker中国的源
	]
} 
		EOF

看清格式,不要有中文不要格式错了,错了就会报错
image

重启docker服务,并查看是否启动成功。(如果重启不成功大概率换源出问题了)

service docker restart
docker info
posted @ 2023-08-23 12:07  向qian看!  阅读(35)  评论(0编辑  收藏  举报