Sell Your Products

Qwixby Marketplace

  • Register for Free
  • Add your products
  • All set for orders

A Quick Docker Engine Overview

We already discussed containers in the previous post and established that the concept of containers is not a new one. However, setting up containers is not a simple task, or at least used to not be, before Docker Engine. Docker Engine is a ridiculously popular tool that makes setting up containers really easy. By containerizing applications, you prevent problems as each container comes with its own libraries and dependencies. In this post, we install docker and run the first image on your installation.

One of the common problems developers have is as an example: when you develop an application on one machine, and then move it to another, and the application doesn’t work. Another headache Docker sole is with regard to updates. If your application carries high traffic loads and you run multiple instances of your application with load balancers and no containers, you end up manually updating each instance, and that can be a big job.

The main purpose of Docker Engine is to Package or Containerize Applications in order to Ship them and Run them Anywhere and Anytime, as Many Times as you want.

The Difference between Docker and Virtual Machines

At first glance, it may seem that Virtual Machines (Hypervisors) and Containers are very similar, but the reality is that each has its own purpose. Docker is very powerful and contributes to DevOps.

DevOps

DevOps is the combination of cultural philosophies, practices, and tools that increases an organization’s ability to deliver applications and services at high velocity.

See AWS What is DevOps

The difference between Docker and Virtual Machines (VMs) is clear in the diagram below. Apart from their different purposes, these two also vary greatly in performance with regards to Resource Utilization and Speed. Containers are lightweight and use fewer resources. Docker makes Microservices possible and allows for applications to be segregated into smaller parts that do not necessarily have to be located on a single piece of hardware. This is done with Namespaces and the intricate networking abilities that is part of Docker Engine/Containers.

VM Vs Docker

Combining VMs with Containers

Quite often you see Docker working together with Virtual Machines. A good example will be Cloud Services like Google Cloud Platform, where you pay for virtual machines and host containerized applications on them. Another classic case of containers working in unison with virtual machines will be if you install Linux based operating systems on a Windows operating system. To do that you use Virtual machines. So, you install VirtualBox as we explained previously, then create a virtual machine and install Linux. Here is a diagram showing that:

Containers on VM's
Docker Engine

Getting To Know Docker

A good place to get to know Docker is to head over to https://hub.docker.com. Here you can sign-up for a free Docker account and join the docker community. Docker is the worlds easiest way to create, manage and deliver your applications. Docker Hub is the world’s largest library and community for docker images.

Docker has two editions or ways you can become part of docker:

  • Community Edition: The Community Edition or Docker CE is open source and completely free. Docker CE offers a set of products aimed at developers and do-it-yourself teams looking to Containerize/Dockerize their applications.
  • Enterprise Edition: Docker Enterprize Edition or Docker EE is designed for enterprize development and IT teams who build, ship and run business critical applications in production at scale. Docker EE is integrated, Certified and Supported to provide the worlds most secure container platform. This obviously comes at a price and incudes many enterprise products with add-ons.

Docker CE is the best place to start if you are new and want to fiddle around with containerization. However, in this tutorial, we install Docker on a local machine. So there is no need to signup just yet. You can work through this tutorial on your computer at home and docker is available for the following systems platforms:

  • Linux
  • Mac
  • Windows
  • Cloud

Docker Images

Previously I mentioned “Images”, so you may be wondering what exactly are Docker Images? Do not confuse Docker Images for files containing graphical content, but rather think of a data file that contains a read-only dataset, more in the lines of a “.iso” file as seen on software installation disks. A Docker Image is a template that contains the set of instructions to create a Container. Therefore, a Docker Image offers an easy and fast way to package your application with already configured server environments and all other dependencies, making your application ready to use on any Docker Platform.

Essentially Images makes sharing your applications simple and combined with Docker Hub, you can share your applications publically. Going the other way, Docker Hub is an Image library with hundreds and thousands of images ready to use, shared by others. Let’s take an example if you want to create a WordPress Website on your localhost without Docker.

First, you need to install a webserver (Apache), PHP, MySql Database Server and then your WordPress Installation. Installing this lot and doing all the configuring to suit your system can take many hours, days or even a week if you don’t know what you are doing. On the flip side, when you use Docker, you run a single command from Terminal and your WordPress website is up and running.

Oh, did I mention you can also take your whole application and turn it into an image that you can share easily? and then push your image to the Docker Hub Registry and make your application available to the public. No more need for developers to send lengthy instructions regarding environments and dependencies to the operators and then operators struggle for days to make applications run. This is truly DevOps.

Time To Install Docker Engine

This example is done with Ubuntu 20.04 64bit, but you can install and use docker on any system. To start the installation, go to https://docs.docker.com

  • Click on the “Download and install” link.
  • Select the system type to install on.
  • Select Your Platform.
  • Go down to the bottom and get the install command.
Install Docker Step 1
Install Docker Step 1
Install Docker Step 2
Install Docker Step 2
Install Docker Step 3
Install Docker Step 3
Install Docker Step 4
Install Docker Step 4

It is a good idea to first check the release details for your system if you don’t know, – Open Terminal and use this

command: cat /etc/release

Docker Install Version
Confirm Your System Release Info

Then uninstall any older versions of docker with this command

sudo apt-get remove docker docker-engine docker.io containerd runc

Convenience Script

The install page for your system shows many ways to install docker, in this example we use the “Convenience Script” located at the bottom of the page. This is the easiest way to install docker. As a good practice, start by updating your system. Once again this command goes in Terminal. Run all the updates and then on to the next step.

sudo apt-get update

After updating use the following command to download the convenience script.

curl -fsSL https://get.docker.com -o get-docker.sh

Then with a second command execute the script to install docker automatically.

sh get-docker.sh

Give the script a few minutes to run and finish the installation.
Once this script is complete you have Docker installed on your machine. An easy way to check your installation is with this command.

sudo docker version

Docker Version
Check Docker Version

Run your first Image

The next step is a way to confirm that Docker is installed correctly. We do that by running an image. Head over to https://hub.docker.com. As you know by now, here you get all the Images you need. For this example, we do a fun install named “Whalesay”. Simply search for it and go to the page. On the result page you get the command to run the image.

Once again in Terminal type or copy/paste the command and run the image.

sudo docker run docker/whalesay cowsay Hello-World!

The process starts with docker not being able to find the image locally and then automatically start the download of the image. Once the download is complete the image runs. It looks something like this.

Run Whalesay - Hello World
Run Whalesay – Hello World

Conclusion

And that is it for this post. You just installed your first Docker installation and ran your first docker image. Subscribe to Quickfood mail notifications and check out our blog for the following tutorials to come. In the next post, we take a look at different Docker commands. You will learn how to ad and remove images, get status on running containers and more. Remember that you can ask any questions you may have in the comments below.

Meet the Author


Renier is a Full Stack PHP Developer who helps businesses with digital transformation. Before starting Quickfood, Renier worked as a technician and a business owner in the hospitality industry and website developer. After a successful career helping various retail stores, leasing agents and more with their websites, Renier now dedicates his time to Cloud-Based Business Applications. Learn how Renier got his start as a Cloud Application Developer.

Leave a Reply

Your email address will not be published.