Last active
August 23, 2024 17:08
-
-
Save jufianto/b68f2c71c147c95cc296c56773139ee0 to your computer and use it in GitHub Desktop.
ubuntu script install docker
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Update the apt package index and install packages to allow apt to use a repository over HTTPS | |
sudo apt-get update | |
sudo apt-get install -y \ | |
apt-transport-https \ | |
ca-certificates \ | |
curl \ | |
gnupg \ | |
lsb-release | |
# Add Docker’s official GPG key | |
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg | |
# Set up the stable repository | |
echo \ | |
"deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu \ | |
$(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null | |
# Update the apt package index again | |
sudo apt-get update | |
# Install the latest version of Docker Engine, containerd, and Docker Compose | |
sudo apt-get install -y docker-ce docker-ce-cli containerd.io docker-compose-plugin | |
# Start Docker and enable it to start on boot | |
sudo systemctl start docker | |
sudo systemctl enable docker | |
# Add the current user to the docker group to run Docker without sudo | |
sudo usermod -aG docker $USER | |
# Verify that Docker Engine is installed correctly by running the hello-world image | |
sudo docker run hello-world | |
newgrp docker | |
# Print Docker version to confirm successful installation | |
docker --version | |
# Inform the user to log out and back in for the group change to take effect | |
echo "Docker installation is complete. Please log out and log back in for the group changes to take effect." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment