Created
October 22, 2025 00:26
-
-
Save alexishida/269ae3891657e2c0bd8c25ad4d65ee6f to your computer and use it in GitHub Desktop.
Install Docker Engine on Ubuntu
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 | |
| #--------------------------------------------------------------------------------------- | |
| # Script to Install Docker Engine on Ubuntu | |
| # Source: https://gist.github.com/alexishida/269ae3891657e2c0bd8c25ad4d65ee6f | |
| # | |
| # Author: Alex Ishida <[email protected]> | |
| # Version: 1.0.0 - 21/10/2025 | |
| # | |
| # References: | |
| # https://docs.docker.com/engine/install/ubuntu/ | |
| # https://docs.docker.com/engine/install/linux-postinstall/ | |
| #--------------------------------------------------------------------------------------- | |
| # Exit on error and undefined variables | |
| set -eu | |
| # Add Docker's official GPG key: | |
| sudo apt-get update | |
| sudo apt-get install ca-certificates curl | |
| sudo install -m 0755 -d /etc/apt/keyrings | |
| sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc | |
| sudo chmod a+r /etc/apt/keyrings/docker.asc | |
| # Add the repository to Apt sources: | |
| echo \ | |
| "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \ | |
| $(. /etc/os-release && echo "${UBUNTU_CODENAME:-$VERSION_CODENAME}") stable" | \ | |
| sudo tee /etc/apt/sources.list.d/docker.list > /dev/null | |
| # Install Docker | |
| sudo apt-get update | |
| sudo apt-get install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin | |
| # Run Docker as a non-root user | |
| sudo groupadd docker | |
| sudo usermod -aG docker $USER | |
| echo "Docker installation completed successfully! =)" | |
| echo "Please log out and log back in for group changes to take effect." | |
| echo "You can test with: docker run hello-world" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment