This commit is contained in:
qiaofeng1227 2024-06-15 15:37:23 +08:00
parent e03fdea9c9
commit 07370c9379

View File

@ -61,6 +61,9 @@ Install_Docker(){
mirror="" mirror=""
fi fi
curl -fsSL --max-time 5 https://get.docker.com -o /dev/null
if [ $? -eq 0 ]; then
# For redhat family # For redhat family
if [[ -f /etc/redhat-release ]] || command -v amazon-linux-extras >/dev/null 2>&1; then if [[ -f /etc/redhat-release ]] || command -v amazon-linux-extras >/dev/null 2>&1; then
# For CentOS, Fedora, or RHEL(only s390x) # For CentOS, Fedora, or RHEL(only s390x)
@ -101,6 +104,55 @@ Install_Docker(){
curl -fsSL https://get.docker.com -o get-docker.sh curl -fsSL https://get.docker.com -o get-docker.sh
timeout $timeout sh get-docker.sh --channel stable --mirror $mirror timeout $timeout sh get-docker.sh --channel stable --mirror $mirror
fi fi
else
echo "can not install by installation script, use special way to install docker"
dnf --version >/dev/null 2>&1
dnf_status=$?
yum --version >/dev/null 2>&1
yum_status=$?
apt --version >/dev/null 2>&1
apt_status=$?
if [ $dnf_status -eq 0 ]; then
sudo dnf install yum-utils -y
sudo dnf config-manager --add-repo https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
sudo dnf install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
elif [ $yum_status -eq 0 ]; then
sudo yum install yum-utils -y
sudo yum-config-manager --add-repo https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
sudo yum install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
elif [ $apt_status -eq 0 ]; then
sudo apt-get update
sudo apt-get install -y ca-certificates curl gnupg lsb-release
curl -fsSL https://mirrors.aliyun.com/docker-ce/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://mirrors.aliyun.com/docker-ce/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update
sudo apt-get install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
else
echo "don't know package tool"
fi
sudo systemctl enable docker
sudo systemctl restart docker
DOCKER_CONFIG_FILE="/etc/docker/daemon.json"
MIRROR_ADDRESS="http://119.8.39.15:5000"
if [ ! -f "$DOCKER_CONFIG_FILE" ]; then
echo "{}" > "$DOCKER_CONFIG_FILE"
fi
if command -v jq >/dev/null 2>&1; then
jq ".\"registry-mirrors\" = [\"$MIRROR_ADDRESS\"]" "$DOCKER_CONFIG_FILE" > "$DOCKER_CONFIG_FILE.tmp" && mv "$DOCKER_CONFIG_FILE.tmp" "$DOCKER_CONFIG_FILE"
else
echo "jq not installed!"
exit 1
fi
sudo systemctl daemon-reload
sudo systemctl restart docker
fi
} }
Upgrade_Docker(){ Upgrade_Docker(){