Skip to content

Commit

Permalink
Implement error handling while installing Docker on the Kubespray VM
Browse files Browse the repository at this point in the history
  • Loading branch information
khanh-ph committed Sep 26, 2023
1 parent de2b2d7 commit 19baf34
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions scripts/setup_kubespray.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,28 @@ wait_for_lock_release() {

wait_for_lock_release

# Install Docker
# Verify if Docker is installed
if ! command -v docker &> /dev/null; then
echo "Docker not found. Installing Docker..."

# Download Docker installation script
if ! curl -fsSL https://get.docker.com -o get-docker.sh; then
echo "Error downloading Docker installation script. Exiting." >&2
exit 1
fi

# Install Docker
curl -fsSL https://get.docker.com -o get-docker.sh
sudo sh get-docker.sh
# Add current user to the docker group
if ! sudo sh get-docker.sh; then
echo "Error installing Docker. Exiting." >&2
exit 1
fi

# Clean up by removing the Docker installation script
rm -f get-docker.sh

# Add current user to the `docker` group
sudo usermod -aG docker $USER

echo "Docker installed successfully."
else
echo "Docker is already installed."
Expand Down

0 comments on commit 19baf34

Please sign in to comment.