Skip to content

Instantly share code, notes, and snippets.

@dmc5179
Last active March 20, 2021 16:55
Show Gist options
  • Save dmc5179/2f55cd54a6fdd103ab1873d52e3464a8 to your computer and use it in GitHub Desktop.
Save dmc5179/2f55cd54a6fdd103ab1873d52e3464a8 to your computer and use it in GitHub Desktop.
Docker CE on RHEL 8 with IPTables
#!/bin/bash
# Add Docker CE Repo
sudo dnf config-manager --add-repo=https://download.docker.com/linux/centos/docker-ce.repo
# Configure Docker CE Repo
sudo sed -i '/^gpgkey=https:\/\/download.docker.com\/linux\/centos\/gpg/a module_hotfixes=True' /etc/yum.repos.d/docker-ce.repo
# Install Docker CE
sudo dnf install -y docker-ce
# Install Docker Compose
sudo curl -L https://github.com/docker/compose/releases/download/1.25.4/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
sudo restorecon -v /usr/local/bin/docker-compose
# Enable IP Forwarding
echo "net.ipv4.ip_forward = 1" | sudo tee -a /etc/sysctl.d/50-docker-forward.conf
# Install IPTables Service
sudo dnf install -y iptables-services
sudo systemctl disable firewalld || true
sudo systemctl disable nftables || true
sudo systemctl enable --now iptables
# Ensure IPTables Modules are loaded at boot
# Not sure if this is required yet
for mod in ip_tables ip_vs_sh ip_vs ip_vs_rr ip_vs_wrr; do sudo modprobe $mod; echo $mod | sudo tee -a /etc/modules-load.d/iptables.conf; done
sudo restorecon -v /etc/sysctl.d/50-docker-forward.conf /etc/modules-load.d/iptables.conf
sudo systemctl enable --now docker
exit 0
@dmc5179
Copy link
Author

dmc5179 commented Mar 27, 2020

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