One-click installation of Docker in Linux environment and configuration of image acceleration

First make sure that the `curl command is installed in the environment,
and then execute the following script

#!/bin/sh

#############################
#安装docker
#############################
if ! type docker >/dev/null 2>&1; then # 未安装docker

curl -sSL https://get.daocloud.io/docker | sh #安装docker

################## 配置国内镜像加速 #####################
sudo -S mkdir -p /etc/docker
sudo tee /etc/docker/daemon.json <<-'EOF'
{
  "registry-mirrors": ["https://docker.mirrors.ustc.edu.cn/"]
}
EOF
sudo systemctl daemon-reload
sudo systemctl restart docker

################### 配置用户组 ##########################
sudo groupadd docker #添加docker用户组
sudo gpasswd -a $USER docker #将登陆用户加入到docker用户组中
newgrp docker #更新用户组

echo "docker安装成功"

fi

Create a new .sh file and execute it in the root environment
insert image description here

After the installation is complete, run the Helloworld test:
docker run hello-world
insert image description here
the installation is successful

Guess you like

Origin blog.csdn.net/x646602196/article/details/129697340