Loading Posts...

Install Docker CE On Ubuntu Server And Deploy Docker Swarm Cluster

Docker is the leading container platform and I have been working with Docker Swarm Cluster configuration in last few weeks on Ubuntu Server 18.04.3 LTS, so I thought to writeup an article to guide my followers, who would like to start the swarm cluster configuration from the scratch, so this is Docker CE on Ubuntu.

Before we start, if you have a question or requirement to clarify what Docker CE (Docker Community Edition) and Docker EE (Enterprise Edition) is, I hope it is the place to start learning Docker.

Docker EE (Enterprise Edition)

Docker EE is the certified container platform for almost all the Operating Systems and Cloud providers, Docker EE provide cooporative support for certified containers and plugins. So, it is the product for official and production use for the containerized applications.

Docker CE (Community Edition)

Docker CE, is the version for the free Docker products. Docker CE is a great full Docker platform for the developers who, actively involved with the development work in the containerized applications. This community supported Docker platform is available for free-of-cost.

Installing Docker CE On Ubuntu

I have deployed Two Virtual Machines with Ubuntu 18.04.3 LTS Operating System and updated the OS before the installation. Below required packages installed prior to the Docker installation. In my screenshots, commands displays as a single line but for the easy visibility, I have added them as lines in my code snippets below

Docker CE On Ubuntu install libraries

Added the Docker GPG Key

And also, added the repository

Docker CE On Ubuntu gpg and repo

Updated the OS and packages, just to make sure we are up-to-date before the installation

Docker CE On Ubuntu update

Installed the Docker CE

Docker CE On Ubuntu install docker ce

Once it completed, we need to add the current user account to the docker user group, otherwise we won’t be able to run the docker commands. Once you added the user make sure to exit and login again, otherwise user permissions will not be applied. Below screen capture shows the permission error after adding my user account to the “docker” user group

Docker CE On Ubuntu add to group

Command successful after exiting and, login in to the system again

Docker CE On Ubuntu images

I have setup two Virtual Machines to work as “Docker Swarm Manager” and “Worker” Nodes. You need to install Docker CE following the above procedures both nodes.

Deploy Docker Swarm Cluster

Now we have successfully installed the Docker CE and, it’s time to deploy the Docker Swarm Cluster. Before that we need to identify the actual interface of the Server which we are going to treat as the Docker Swarm Manager. If you just execute the “ifconfig” command, you might be seen few interfaces and you need to identify the actual network interface to initialize the Docker Swarm Cluster.

Read More: How To Start Working With Google Kubernetes Engine (GKE)

After identifying the interface, initialize the cluster with the below command and, make sure to note down the command displaying after that, which we need to use in Worker nodes to connect them to the Docker Manager. It consists the “Join Token” for the worker node.

Docker CE On Ubuntu pick IP

Execute the displayed command in the other Virtual Machine to act it as the Worker Node, and join to the Swarm Cluster.

Docker CE On Ubuntu worker join

To check the cluster status, execute below command and you can identify the Docker Manager as the “Leader”, under “Manager Status

Docker CE On Ubuntu node list

So, we have a two node Docker Swarm Cluster configured and let’s see few other essential commands for ease of use.

Just assume that you forgot the “Join Token” for the worker node, and you need to connect another Docker Manager to the cluster. You can generate the “Join Tokens” again with below commands

Docker CE On Ubuntu join tokens

Deploy A Sample Web Service In The Docker Swarm Cluster

Let’s see how we can deploy a simple web service on the Docker Swarm cluster.

We do not have the downloaded Docker images yet, and I have deployed a simple web service in the swarm cluster with two replicas. Theses replicas automatically distributed in these two nodes to provide the high availability to the application.

Docker CE On Ubuntu serice on swarm

So now, we have successfully deployed a Docker Swarm Cluster and run a service with two replicas on an Ubuntu Servers successfully.

Aruna Lakmal

Associate Technical Specialist at Pearson, Sri Lanka. Technology junky, enthusiast, a VMware vExpert and a blogger with more than 7 years of Experience in Information Technology more focusing on VMware Virtualization, Microsoft and Datacenter Technologies.

Get Updates Directly To Your Inbox!

   

Leave a Reply

Loading Posts...