Skip to content

Instantly share code, notes, and snippets.

@yadav-vikas
Last active August 5, 2023 21:40
Show Gist options
  • Save yadav-vikas/cc0ea3174b4b6db4b20b6ecc91800607 to your computer and use it in GitHub Desktop.
Save yadav-vikas/cc0ea3174b4b6db4b20b6ecc91800607 to your computer and use it in GitHub Desktop.
How to download and install docker on linux
#1. Please Download this files in your system
2. Please change it to executable files in your directory
(you can run `sudo chmod +x __file_name__.sh`
#!/bin/sh
sudo apt update
echo "checking updates before installing Docker..."
echo "installing prerequisite packages for Docker."
sudo apt install apt-transport-https ca-certificates curl software-properties-common
echo "adding the GPG key for the official Docker repository to your system."
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
echo "Adding the Docker repository to APT sources..."
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu focal stable"
echo "adding cache to install from the Docker repo instead of the default Ubuntu repo."
apt-cache policy docker-ce
echo "Setup Complete."
echo "installing Docker..."
sudo apt install docker-ce
echo "checking Docker status..."
sudo systemctl is-active docker
echo "Docker installed successfully!!"
echo "Installing 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
docker-compose --version
echo "docker-compose is ready!."
echo "Would you like to add Docker to groups and access directly(in other words executing the Docker Command without Sudo) ?"
while true
do
read -r -p 'Do you want to continue? ' choice
case "$choice" in
n|N) break;;
y|Y) sudo usermod -aG docker ${USER};
su - ${USER};
echo "Docker has been added to sudo.";;
*) echo 'Response not valid';;
esac
done
#!/bin/sh
sudo apt-get update
sudo apt-get install -y ca-certificates curl
sudo apt-get install -y apt-transport-https
DIR="/etc/apt/keyrings/"
if [ -d "$DIR" ]; then
echo "'$DIR' found and now copying files, please wait ..."
else
echo "'$DIR' NOT found!!"
echo "creating 'keyrings' directory"
sudo mkdir /etc/apt/keyrings/
echo "copying files in $DIR, please wait..."
fi
sudo curl -fsSLo /etc/apt/keyrings/kubernetes-archive-keyring.gpg https://packages.cloud.google.com/apt/doc/apt-key.gpg
echo "deb [signed-by=/etc/apt/keyrings/kubernetes-archive-keyring.gpg] https://apt.kubernetes.io/ kubernetes-xenial main" | sudo tee /etc/apt/sources.list.d/kubernetes.list
sudo apt-get update
sudo apt-get install -y kubectl
echo "kubectl installation complete."
echo "Adding kubectl autocompletes for 'bash'..."
#source kubectl completion bash
#bash-completion package for autocompletion.
echo "source <(kubectl completion bash)" >> ~/.bashrc
# add autocomplete permanently to your bash shell.
kubectl cluster-info
#!/bin/sh
curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64
sudo install minikube-linux-amd64 /usr/local/bin/minikube
echo "minikube is installed."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment