Spaces:
Build error
Build error
File size: 3,678 Bytes
59c3a37 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 |
#!/bin/bash
echo "[INFO]: Removing previous verions of dockers..."
echo "[INFO]: Removing previous verions of dockers..." > logs.txt
if sudo apt-get remove docker docker-engine docker.io containerd runc -y >> logs.txt; then
echo "[INFO]: Previous docker removed successfully!"
echo "[INFO]: Previous docker removed successfully!" >> logs.txt
fi
echo "[INFO]: Updating apt-package index..."
echo "[INFO]: Updating apt-package index..." >> logs.txt
if sudo apt-get update -y >> logs.txt; then
echo "[INFO]: apt-package index updated successfuly!"
echo "[INFO]: apt-package index updated successfuly!" >> logs.txt
else
echo "[ERROR]: Error while updating apt-package index. Check logs.txt file for more info."
echo "[ERROR]: Error while updating apt-package index." >> logs.txt
# exit 1
fi
echo "[INFO]: Installing required apt packages..."
echo "[INFO]: Installing required apt packages..." >> logs.txt
if sudo apt-get install \
ca-certificates \
curl \
gnupg \
lsb-release -y ; then
echo "[INFO]: Required apt packages installed successfully!"
echo "[INFO]: Required apt packages installed successfully!" >> logs.txt
else
echo "[ERROR]: Error installing required apt packages. Check logs.txt file for more info."
echo "[ERROR]: Error installing required apt packages." >> logs.txt
exit 1
fi
echo "[INFO]: Adding docker GPG key..."
echo "[INFO]: Adding docker GPG key..." >> logs.txt
sudo mkdir -p /etc/apt/keyrings
if curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg >> logs.txt;then
echo "[INFO]: Docker GPG key added successfully!"
echo "[INFO]: Docker GPG key added successfully!" >> logs.txt
else
echo "[ERROR]: Error adding docker GPG key. Check logs.txt file for more info."
echo "[ERROR]: Error adding docker GPG key." >> logs.txt
exit 1
fi
echo "[INFO]: Setting docker repository..."
echo "[INFO]: Setting docker repository..." >> logs.txt
if echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null >> logs.txt; then
echo "[INFO]: Docker repository setup done."
echo "[INFO]: Docker repository setup done." >> logs.txt
else
echo "[ERROR]: Error setting up docker repository. Check logs.txt file for more info."
echo "[ERROR]: Error setting up docker repository." >> logs.txt
exit 1
fi
echo "[INFO]: Installing Docker Engine..."
echo "[INFO]: Installing Docker Engine..." >> logs.txt
if sudo apt-get update -y >> logs.txt; then
if sudo apt-get install docker-ce docker-ce-cli containerd.io docker-compose-plugin -y >> logs.txt; then
if sudo docker --version; then
echo "[INFO]: Docker Engine instaleld successfully!"
echo "[INFO]: Docker Engine instaleld successfully!" >> logs.txt
fi
else
echo "[ERROR]: Error installing docker engine. Check logs.txt file for more info."
echo "[ERROR]: Error installing docker engine." >> logs.txt
exit 1
fi
else
echo "[ERROR]: Error updating apt packages. Check logs.txt file for more info."
echo "[ERROR]: Error updating apt packages." >> logs.txt
# exit 1
fi
echo "[INFO]: Adding docker to sudo group..."
echo "[INFO]: Adding docker to sudo group..." >> logs.txt
sudo xhost +local:docker
sudo groupadd docker
sudo gpasswd -a $USER docker
newgrp docker
echo "[INFO]: Docker Installation and setup completed successfully!"
echo "[INFO]: Docker Installation and setup completed successfully!" >> logs.txt |