Skip to content

Instantly share code, notes, and snippets.

@m-primo
Last active December 10, 2023 22:19
Show Gist options
  • Save m-primo/25694df8ed0ef20ca752c0dd3d35e135 to your computer and use it in GitHub Desktop.
Save m-primo/25694df8ed0ef20ca752c0dd3d35e135 to your computer and use it in GitHub Desktop.
Quick Docker installation for Linux distros in one gist. (I have added this for my personal use, feel free to use & edit it however you like)
#!/bin/bash
# Make sure to run the file as super user (sudo) first.
# https://docs.docker.com/engine/install/centos/
# Install the yum-utils package to have yum-config-manager
yum install -y yum-utils
# Add Docker to the packages repository
yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
# Install Docker Engine, containerd & Docker Compose
yum install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
# Enable & start Docker service
systemctl enable --now docker
# Test Docker
docker run hello-world
#!/bin/bash
# Make sure to run the file as super user (sudo) first.
# https://docs.docker.com/engine/install/debian/
# Update the local packages db first
apt-get update -y
# Install the certificate authority, curl, gnupg
apt-get install ca-certificates curl gnupg -y
# Download & add the Docker's key
install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/debian/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
chmod a+r /etc/apt/keyrings/docker.gpg
# Add Docker to the packages repository
echo \
"deb [arch="$(dpkg --print-architecture)" signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/debian \
"$(. /etc/os-release && echo "$VERSION_CODENAME")" stable" | \
tee /etc/apt/sources.list.d/docker.list > /dev/null
# Update the packages repository index
apt-get update -y
# Install Docker Engine, containerd & Docker Compose
apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin -y
# Test Docker
docker run hello-world
#!/bin/bash
# Make sure to run the file as super user (sudo) first.
# https://docs.rockylinux.org/gemstones/docker/
# Update the package database
dnf check-update
# Add the docker repository
dnf config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
# Install the latest version of Docker Engine, containerd, and Docker Compose
dnf -y install docker-ce docker-ce-cli containerd.io docker-compose-plugin
# Start and enable the systemd docker service
systemctl enable --now docker
# Verify that Docker is working properly
docker run hello-world
#!/bin/bash
# Make sure to run the file as super user (sudo) first.
# https://docs.docker.com/engine/install/ubuntu/
# Update the local packages db first
apt-get update -y
# Install the certificate authority, curl, gnupg
apt-get install ca-certificates curl gnupg -y
# Download & add the Docker's key
install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
chmod a+r /etc/apt/keyrings/docker.gpg
# Add Docker to the packages repository
echo \
"deb [arch="$(dpkg --print-architecture)" signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
"$(. /etc/os-release && echo "$VERSION_CODENAME")" stable" | \
tee /etc/apt/sources.list.d/docker.list > /dev/null
# Update the packages repository index
apt-get update -y
# Install Docker Engine, containerd & Docker Compose
apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin -y
# Test Docker
docker run hello-world
@m-primo
Copy link
Author

m-primo commented Jun 4, 2023

To use directly into your system, copy the raw url of the destination file above, and then run the following command:

With cURL:

sudo su
curl <url> | bash

With wget:

sudo su
wget -O - <url> | bash

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment