功能描述
在Amazon Linux 上自动安装Docker and Docker-compose
#!/bin/bash
# @Author : Lan Shiyun
# @Create Time : 2024/3/15
# @FileName : install_docker_4_aws_.sh
# @Version : 1.0
# @Software : VS Code
# @Update Time : 2024/3/15
# @UpdateBy : Lan Shiyun
# @Description : Shell script to install Docker and Docker Compose on Amazon Linux
# Main function to control the installation process
main() {
# Check if Docker is already installed
if ! command -v docker &> /dev/null; then
echo "Installing Docker..."
install_docker
else
echo "Docker is already installed."
fi
# Check if Docker Compose is already installed
if ! command -v docker-compose &> /dev/null; then
echo "Installing Docker Compose..."
install_docker_compose
else
echo "Docker Compose is already installed."
fi
}
# Function to install Docker
install_docker() {
sudo yum update -y
sudo amazon-linux-extras install docker -y
sudo systemctl start docker
sudo systemctl enable docker
sudo usermod -aG docker $USER
}
# Function to install Docker Compose
install_docker_compose() {
sudo curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
}
# Call the main function to start the installation process
main
标签:Shell,Compose,sudo,compose,install,Docker,docker
From: https://www.cnblogs.com/lanshiyun/p/18075075