ol9-docker
· 1.7 KiB · Text
原始檔案
#!/bin/bash
set -e
echo "[+] Installing Docker CE on Oracle Linux 9..."
/usr/bin/timedatectl set-timezone Europe/Moscow
# Enable required repos
echo "[+] Enabling required Oracle Linux repositories..."
dnf install -y dnf-plugins-core oraclelinux-developer-release-el9 tmux nano openssh-server git
dnf config-manager --enable ol9_developer
echo '[*] Enabling root SSH login...'
sudo sed -i 's/^#\?PermitRootLogin .*/PermitRootLogin yes/' /etc/ssh/sshd_config || echo 'PermitRootLogin yes' | sudo tee -a /etc/ssh/sshd_config
curl https://gist.zubovspace.com/dszubov/2a97f1f8d4764a7eaf9dc5704735f094/raw/HEAD/sshd_config > /etc/ssh/sshd_config
sudo systemctl restart sshd
sudo systemctl enable sshd
echo "[INFO] Installing htop..."
sudo dnf install -y epel-release
sudo dnf install -y htop
mkdir -p ~/.config/htop/
# Install container-selinux
echo "[+] Installing container-selinux..."
dnf install -y container-selinux
# Disabling firewall and selinux
setenforce 0
systemctl stop firewalld
systemctl disable firewalld
# Add Docker CE repo
echo "[+] Adding Docker CE repo..."
dnf install -y dnf-utils
dnf config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
# Install Docker CE and plugins
echo "[+] Installing Docker CE and plugins..."
dnf install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
# Enable and start Docker
echo "[+] Enabling and starting Docker service..."
systemctl enable --now docker
# Optional: add current user to docker group
if [ "$SUDO_USER" ]; then
echo "[+] Adding $SUDO_USER to docker group..."
usermod -aG docker "$SUDO_USER"
fi
echo "[+] Docker installation complete!"
echo ">> Run 'docker run hello-world' to test it"
| 1 | #!/bin/bash |
| 2 | set -e |
| 3 | |
| 4 | echo "[+] Installing Docker CE on Oracle Linux 9..." |
| 5 | /usr/bin/timedatectl set-timezone Europe/Moscow |
| 6 | |
| 7 | # Enable required repos |
| 8 | echo "[+] Enabling required Oracle Linux repositories..." |
| 9 | dnf install -y dnf-plugins-core oraclelinux-developer-release-el9 tmux nano openssh-server git |
| 10 | dnf config-manager --enable ol9_developer |
| 11 | |
| 12 | echo '[*] Enabling root SSH login...' |
| 13 | sudo sed -i 's/^#\?PermitRootLogin .*/PermitRootLogin yes/' /etc/ssh/sshd_config || echo 'PermitRootLogin yes' | sudo tee -a /etc/ssh/sshd_config |
| 14 | curl https://gist.zubovspace.com/dszubov/2a97f1f8d4764a7eaf9dc5704735f094/raw/HEAD/sshd_config > /etc/ssh/sshd_config |
| 15 | sudo systemctl restart sshd |
| 16 | sudo systemctl enable sshd |
| 17 | |
| 18 | echo "[INFO] Installing htop..." |
| 19 | sudo dnf install -y epel-release |
| 20 | sudo dnf install -y htop |
| 21 | mkdir -p ~/.config/htop/ |
| 22 | |
| 23 | # Install container-selinux |
| 24 | echo "[+] Installing container-selinux..." |
| 25 | dnf install -y container-selinux |
| 26 | |
| 27 | # Disabling firewall and selinux |
| 28 | setenforce 0 |
| 29 | systemctl stop firewalld |
| 30 | systemctl disable firewalld |
| 31 | |
| 32 | # Add Docker CE repo |
| 33 | echo "[+] Adding Docker CE repo..." |
| 34 | dnf install -y dnf-utils |
| 35 | dnf config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo |
| 36 | |
| 37 | # Install Docker CE and plugins |
| 38 | echo "[+] Installing Docker CE and plugins..." |
| 39 | dnf install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin |
| 40 | |
| 41 | # Enable and start Docker |
| 42 | echo "[+] Enabling and starting Docker service..." |
| 43 | systemctl enable --now docker |
| 44 | |
| 45 | # Optional: add current user to docker group |
| 46 | if [ "$SUDO_USER" ]; then |
| 47 | echo "[+] Adding $SUDO_USER to docker group..." |
| 48 | usermod -aG docker "$SUDO_USER" |
| 49 | fi |
| 50 | |
| 51 | echo "[+] Docker installation complete!" |
| 52 | echo ">> Run 'docker run hello-world' to test it" |