Installing Docker on CentOS7

Although I’ve been playing with Docker for Mac (yes, I have a MacBook Pro on macOS 10.13), I wanted to test out Docker Swarm and the Unified Control Plane (UCP), but you can’t do that with the CE edition, you have to be running the Enterprise Edition (EE).  So, after submitting for my 1 month trial, I powered up VMware Fusion and installed CentOS 7 Minimal installation.
NOTE:  If you’re wondering why VMware Fusion instead of VirtualBox, the reason has to do with the better control that Fusion has over VB– though when VB get’s that level of granularity enabled, I’ll give it a try as well for lower TCO.

Step-by-Step

Initially five (5) CentOS machines fora docker Swarm (1 Manager (though I’d prefer three), and four  Workers). Future may add two more machines as I look further into the UCP requirements.

Get OS and Docker EE Trial, and install basic CentOS7

  1. Downloaded CentOS 7 Minimal
    • Docker is really aCLI and API driven over a browser interface, so minimal is fine.
  2. Headed over to http://store.docker.com, signed in, clicked Docker EE and grabbed my trial Docker EE license (good for 30 days)
  3. Install CentOS from downloaded image as follows:
    • VMware Fusion Settings – Bridged Network (not sharing Mac IP)
    • DVD set to the CentOS Minimal DVD image
    • DHCP (since I intend on cloning this image)
    • Set hostname and local search domain (Docker-Mgr-01.example.com)
    • Configure a root and normal user
  4. Update /etc/hosts with planned hostnames
    • e.g.,
      172.16.1.101    docker-mgr-01 docker-mgr-01.example.org
      172.16.1.111    docker-node-01 docker-node-01.example.org
      172.16.1.112    docker-node-02 docker-node-02example.org
      172.16.1.113    docker-node-03 docker-node-03.example.org
      172.16.1.114    docker-node-04 docker-node-04.example.org
  5. Power off the VM and clone four times. (OPTIONAL, or DEFER TO LATER)
    • (You can do this before or after you install Docker– I believe repetition helps with learning, so I cloned the image here… if you don’t want to install Docker repeatedly, clone at any point you desire here after)

Update Network

    1. Using nmtui (or whatever method you prefer), set the IP to static, and adjust the hostname and domain to match the plan
    2. Open https://docs.docker.com/install/linux/docker-ee/centos/ and follow the instructions.
    3. Set the DOCKERURL to the URL that you get from Docker
      • export DOCKERURL=”
    4. Add the Docker EE repository for yum
      • sudo -E sh -c ‘echo “$DOCKERURL/centos” > /etc/yum/vars/dockerurl’
    5. Install the yum-utils
      • sudo yum install -y yum-utils  device-mapper-persistent-data   lvm2
      • RECOMMENDATION:  Don’t use the drivemapper storage driver, but stick with the default overlayfs2.
    6. Enable the docker service and then turn it on
      • sudo systemctl enable docker
      • sudo systemctl start docker
    7. Add your user to the docker group
      • sudo usermod -aG docker
      • Logout and logback in
      • enter ‘groups’ to confirm you are now a part of the docker management group

If you will be using Docker Swarm, do the following:

  1. If you are going to use Docker Swarm (presumably you are if you have multiple VMs), open the following ports in the firewall daemon: 2376/tcp, 2377/tcp, 7946/tcp, 7946/udp, 4789/udp
    • Or just cut and paste the following command in a bash shell if using firewalld:
    • firewall-cmd --add-port=2376/tcp --permanent; firewall-cmd --add-port=2377/tcp --permanent; firewall-cmd --add-port=7946/tcp --permanent; firewall-cmd --add-port=7946/udp --permanent; firewall-cmd --add-port=4789/udp --permanent;
  2. If using Docker Swarm, repeat steps 5 through 12 for each remaining VM.

 

Leave a Reply