Last active
July 18, 2024 17:29
-
-
Save mmaous/1536195255a41b6989e1e0faf014b6b1 to your computer and use it in GitHub Desktop.
Install Docker on a Debian-based system and configure Docker to run without sudo
This file contains 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 | |
# Step 1: Installing Docker | |
# Update the package list | |
sudo apt update | |
# Install prerequisite packages | |
sudo apt install -y apt-transport-https ca-certificates curl gnupg2 software-properties-common | |
# Add Docker's GPG key | |
curl -fsSL https://download.docker.com/linux/debian/gpg | sudo apt-key add - | |
# Add Docker repository to APT sources | |
sudo add-apt-repository -y "deb [arch=amd64] https://download.docker.com/linux/debian $(lsb_release -cs) stable" | |
# Update package database | |
sudo apt update | |
# Check Docker version | |
apt-cache policy docker-ce | |
# Install Docker | |
# sudo apt install -y docker-ce | |
sudo apt install -y docker.io | |
# Check Docker status | |
# sudo systemctl status docker | |
# Step 2: Allowing Docker to be run without sudo (Optional) | |
# Add the current user to the docker group | |
sudo usermod -aG docker $USER | |
# Apply the new group membership | |
sudo su - $USER | |
# Confirm group membership | |
id -nG | |
# install docker compose | |
DOCKER_CONFIG=${DOCKER_CONFIG:-$HOME/.docker} | |
mkdir -p $DOCKER_CONFIG/cli-plugins | |
curl -SL https://github.com/docker/compose/releases/download/v2.29.0/docker-compose-linux-x86_64 -o $DOCKER_CONFIG/cli-plugins/docker-compose | |
chmod +x $DOCKER_CONFIG/cli-plugins/docker-compose | |
# Provide instructions to the user | |
echo "Docker & Docker Compose is now installed and configured to run without sudo." | |
echo "Please log out and back in or restart your system for the changes to take effect." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment