-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathinstall-docker_rhel8-9.sh
executable file
·58 lines (39 loc) · 1.9 KB
/
install-docker_rhel8-9.sh
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/bin/bash
###################################################
# Docker Install - CentOS Stream 8-9 / RHEL 8-9
###################################################
# Reference: https://tecadmin.net/how-to-install-docker-on-centos-stream-9/
###### TL;DR ######
# If needed, use this script to install Docker on your RHEL(-esque) OS.
# This will delete any previous installs you may or may not have on your system.
### Script finishes with a "Hello World" test run. If this is unsuccessful, you can try re-running this script.
### If the test run still fails, maybe I f***ed up; try running some other Docker command on your own.
### Still failing? Look at your firewall or IP-tables configs. Therein (likely) lies your problem...
##### Still STILL failing? Hm... try a custom Docker network and define it as an external network in the compose.yml file. Check the "custom-network.sh" file for more details...
##### (ref: https://docs.docker.com/engine/reference/commandline/network_create/)
##### (ref: https://docs.docker.com/compose/networking/)
###################
# Fresh start:
sudo dnf erase -y docker > /dev/null 2>&1
sudo dnf update -y
# Install necessary dependencies for Docker:
sudo dnf install -y yum-utils device-mapper-persistent-data lvm2
# Add Docker repository:
sudo dnf config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
# Install Docker Community Edition (CE) (--nobest installs highest version that satisfies package dependencies):
sudo dnf install -y docker-ce --nobest
# Start/enable Docker service:
sudo systemctl enable --now docker
# Verify Docker status and version
if [[ $(systemctl status docker | grep "active (running)") == "" ]]
then
sudo systemctl start docker > /dev/null 2>&1
systemctl status docker
else
systemctl status docker
fi
sudo docker --version
# Configure Docker to run without sudo:
sudo usermod -aG docker $USER
# Test run:
docker run --rm hello-world