Please note that this setup is not recommended for production use, but can be convenient for development/demo purposes.

Docker installation

Install needed packages:

1
$ sudo yum install -y yum-utils device-mapper-persistent-data lvm2

Configure the docker-ce repo:

1
$ sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo

Install docker-ce:

1
$ sudo yum install docker-ce

Create Docker group:

1
$ sudo groupadd docker

It appeared that docker.sock was owned by root and in the group root:

1
2
3
$ ls -l /var/run/docker.sock

srw-rw---- 1 root root 0 May 6 15:42 /var/run/docker.sock

Changing the group ownership:

1
2
3
4
5
$ sudo chown root:docker /var/run/docker.sock

$ ls -l /var/run/docker.sock

srw-rw---- 1 root docker 0 May 6 15:42 /var/run/docker.sock

Add your user to the docker group with the following command.

1
$ sudo usermod -aG docker $(whoami)

Set Docker to start automatically at boot time:

1
$ sudo systemctl enable docker.service

Finally, start the Docker service:

1
$ sudo systemctl start docker.service

Logging back on, now can run docker commands without sudo.

Docker-compose installation

Install Extra Packages for Enterprise Linux

1
2
3
4
5
6
7
$ sudo yum install epel-release
Install python-pip

$ sudo yum install -y python-pip
Then install Docker Compose:

$ sudo pip install docker-compose

You will also need to upgrade your Python packages on CentOS 7 to get docker-compose to run successfully:

1
$ sudo yum upgrade python*

To verify a successful Docker Compose installation, run:

1
$ docker-compose version

Rancher 2 installation

1
2
3
4
5
$ docker run -d --restart=unless-stopped \
-p 8080:80 -p 8443:443 \
-v /opt/rancher:/var/lib/rancher \
rancher/rancher:latest \
--acme-domain <DNS_GUI_RANCHER>

In the situation where you want to use a single node to run Rancher and to be able to add the same node to a cluster, you have to adjust the host ports mapped for the rancher/rancher container.

If a node is added to a cluster, it deploys the nginx ingress controller which will use port 80 and 443. This will conflict with the default ports we advise to expose for the rancher/rancher container.