Skip to content

Instantly share code, notes, and snippets.

@madkoding
Last active March 19, 2024 00:52
Show Gist options
  • Star 54 You must be signed in to star a gist
  • Fork 20 You must be signed in to fork a gist
  • Save madkoding/3f9b02c431de5d748dfde6957b8b85ff to your computer and use it in GitHub Desktop.
Save madkoding/3f9b02c431de5d748dfde6957b8b85ff to your computer and use it in GitHub Desktop.
Install Docker-CE script for Deepin Linux
#!/bin/bash
echo "Starting Docker installation on Deepin Linux..."
# Define a mapping from Deepin version to Debian version
map_deepin_to_debian() {
if [ "$1" -lt 20 ]; then
echo "stretch"
elif [ "$1" -ge 20 ]; then
echo "buster"
else
echo "Unknown version of Deepin"
exit 1
fi
}
# Get Deepin version
DEEPIN_VERSION=$(grep 'VERSION_ID' /etc/os-release | cut -d '"' -f 2)
DEBIAN_VERSION=$(map_deepin_to_debian "$DEEPIN_VERSION")
echo "Deepin version: $DEEPIN_VERSION, using Debian version: $DEBIAN_VERSION for Docker installation."
# Update and install dependencies
echo "Updating packages and installing dependencies..."
sudo apt-get update -y
sudo apt-get install -y apt-transport-https ca-certificates curl gnupg2 software-properties-common || { echo "Failed to install dependencies"; exit 1; }
# Check if Docker is installed and remove it
if dpkg -l | grep -qw docker; then
echo "Removing old Docker versions..."
sudo apt-get remove -y docker docker-engine docker.io containerd runc || { echo "Failed to remove existing Docker installations"; exit 1; }
fi
# Add Docker's official GPG key
echo "Adding Docker's GPG key..."
curl -fsSL https://download.docker.com/linux/debian/gpg | sudo apt-key add - || { echo "Failed to add Docker's GPG key"; exit 1; }
# Verify key with fingerprint
sudo apt-key fingerprint 0EBFCD88
# Add Docker repository
echo "Adding Docker repository for $DEBIAN_VERSION..."
printf "deb [arch=amd64] https://download.docker.com/linux/debian $DEBIAN_VERSION stable\n" | sudo tee /etc/apt/sources.list.d/docker-ce.list || { echo "Failed to add Docker repository"; exit 1; }
# Install Docker CE
echo "Installing Docker CE..."
sudo apt-get update -y
sudo apt-get install -y docker-ce || { echo "Failed to install Docker CE"; exit 1; }
# Add current user to the Docker group (optional)
echo "Adding current user to the Docker group..."
sudo usermod -aG docker $(whoami) || { echo "Failed to add user to Docker group"; exit 1; }
echo "Docker installation and setup completed successfully."
@HarborZeng
Copy link

yes this really helped me

@freinet12
Copy link

this is awesome

@loverdeveloper
Copy link

It's great,
Thanks @madkoding

@madkoding
Copy link
Author

Added in the script the add docker to user group from @juliocv

@ulises-castro
Copy link

Thanks so much bro, It worked.

@filipepfarias
Copy link

Thx. Really helped me.

@omids04
Copy link

omids04 commented Jun 15, 2020

good job. thx

@ranjian0
Copy link

ranjian0 commented Sep 8, 2020

Worked like a charm

@wlad
Copy link

wlad commented Jan 1, 2021

shouldn't one use buster for deepin 20.1 (1010) ?

printf 'deb [arch=amd64] https://download.docker.com/linux/debian buster stable\n' \
| sudo tee /etc/apt/sources.list.d/docker-ce.list

@madkoding
Copy link
Author

shouldn't one use buster for deepin 20.1 (1010) ?

printf 'deb [arch=amd64] https://download.docker.com/linux/debian buster stable\n' \
| sudo tee /etc/apt/sources.list.d/docker-ce.list

Updated

@Davi-zzz
Copy link

u are a hero bro!

@chemscobra
Copy link

Dude Thanks!

@madkoding
Copy link
Author

hey people, i just a long time i'm no longer use deepin linux, so, if i need to update the script just tell me in the comments

@marcoscunhaa
Copy link

you save my life !

@Alaa-Ellethey
Copy link

thanks alot

@vanotis720
Copy link

vanotis720 commented Apr 7, 2022

work fine in deepin 20! thanks

@BSoDium
Copy link

BSoDium commented May 31, 2022

This, fine sir is a very helpful script, thanks a lot !

@SoderJuliano
Copy link

SoderJuliano commented May 1, 2023

It helped me thanks :) 👍 Beta Deeping Linux 23
Also I had to run another command before those, for work -> sudo nano /etc/*-release and save the files with "Ctrl+O" (to save) and "Ctrl+x" (to quit)

The issue I had its solved here: elementary/os-patches#136

@madkoding
Copy link
Author

Updated script

@sacsbrainz
Copy link

my version to that worked on deepin V23 Beta2(Unstable)

https://gist.github.com/sacsbrainz/e6572da7238ed21d0cb8cab6b9b0480f

@madkoding
Copy link
Author

madkoding commented Dec 14, 2023

Replaced map_deepin_to_debian method, if lower version than 20 will use debian stretch, if equal or higher will use debian buster. That will be enough to work in deepin V23 Beta2 and future realeases

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