-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-func
More file actions
42 lines (37 loc) · 1.25 KB
/
docker-func
File metadata and controls
42 lines (37 loc) · 1.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/bin/bash
install-docker () {
# Find if Debian or Ubuntu
. /etc/os-release
OS="${NAME}"
case ${OS,,} in
*ubuntu*)
OS='ubuntu'
;;
*debian*)
OS='debian'
;;
*)
echo "OS unknown, stopping docker install..."
return 1
;;
esac
echo -e "\nInstalling Docker for ${OS}..."
# Setup prereqs and remove outdated packages
for pkg in docker.io docker-doc docker-compose podman-docker containerd runc
do
apt remove $pkg -y
done
apt update -y
apt install ca-certificates curl gnupg lsb-release jq -y
install -m 0755 -d /etc/apt/keyrings
curl -fsSL "https://download.docker.com/linux/${OS}/gpg" | gpg --dearmor -o /etc/apt/keyrings/docker.gpg
chmod a+r /etc/apt/keyrings/docker.gpg
# Add repository
echo \
"deb [arch="$(dpkg --print-architecture)" signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/${OS} \
"$(. /etc/os-release && echo "$VERSION_CODENAME")" stable" | \
tee /etc/apt/sources.list.d/docker.list > /dev/null
apt update -y
# Install Docker
apt install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin acl -y
}