Skip to content

Instantly share code, notes, and snippets.

@jeffmccollum
Forked from abuxton/rhel7-docker-install.sh
Last active July 1, 2022 13:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jeffmccollum/ff34752b9a1f577d5ef2702640ec3f43 to your computer and use it in GitHub Desktop.
Save jeffmccollum/ff34752b9a1f577d5ef2702640ec3f43 to your computer and use it in GitHub Desktop.
rhel7-docker-install
#! /bin/bash +X
# Script to install Docker on RHEL for TFE
# This script can be run separately or inserted into the userdata script. If inserted into a userdata script, remove the sudo commands as the userdata is already running with sudo
# This has been tested with selinuxmode set to permissive
# sudo setenforce Permissive
# To check selinuxmode
# getenforce
# Remove any docker components already installed
sudo yum remove docker docker-common docker-selinux docker-engine-selinux docker-engine docker-ce
# Now install some tools dmpd(for short) ensures rhel 7 respects gpg settings in repos (issue is https://access.redhat.com/solutions/2850911) see https://access.redhat.com/discussions/5336741 for the fix
sudo yum install -y yum-utils device-mapper-persistent-data lvm2
sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
## ok now we have some unmet dependencies and it gets a little hacky (note these are not available in https://dl.fedoraproject.org/pub/epel/7/x86_64/Packages/)
# source from centos/os repo
sudo cat > /etc/yum.repos.d/centos-os.repo << EOF
[centos-os]
name=Centos os
baseurl=http://mirror.centos.org/centos/7/os/x86_64/
enabled=1
gpgcheck=0
EOF
sudo yum install -y libcgroup-tools
# get the rest of the dependencies https://stackoverflow.com/a/66902898/2362673
sudo cat > /etc/yum.repos.d/centos-extras.repo << EOF
[centos-extras]
name=Centos extras
baseurl=http://mirror.centos.org/centos/7/extras/x86_64
enabled=1
gpgcheck=0
EOF
sudo yum install -y slirp4netns fuse-overlayfs container-selinux
# finally install docker
sudo yum install -y docker-ce-20.10.7-3.el7 docker-ce-cli-20.10.7-3.el7 containerd.io
# start docker
sudo systemctl start docker
# check installed docker version
docker version
# docker suggested test for reference https://docs.docker.com/engine/install/rhel/
# sudo docker run hello-world
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment