DEV Community

Cover image for Docker and Docker Containers: An Overview
Suresh Mohan for Syncfusion, Inc.

Posted on • Originally published at syncfusion.com on

Docker and Docker Containers: An Overview

The name Docker suggests goods, packed in containers, moving on and off ships. Following this imagery, Docker is a tool that helps ship software products as containers. With the enormous increase in the use of microservices, hosting them individually is a tedious task, but they can also be containerized like any other application. Docker helps create these microservices containers, move them from one place to another, and deploy them.

What is Docker?

Docker is a standard tool for packaging apps into containers by virtualizing them, including their OS and all other dependencies. It is a platform-as-a-service (PaaS) product. Though the concept of virtualization has been in tech for a long time, Docker wasn’t released until 2013 by Docker, Inc. Docker takes an app and makes it a container.

Containers are entities that run an app independently, regardless of the environment. Containers can be created from anything, from static HTML content to framework apps. Docker Engine has a daemon that services the running of containers which is used in several areas, including integration testing.

Why should you containerize?

Imagine you have an app up and running on your local machine. For people to access it, you deploy it on the internet using any cloud provider or in a bare-metal environment.

The environment in which you developed your product (for example, Windows 10 or Angular 10) and the environment the product is in, whether on the cloud or a physical machine, may not be the same.

Even if the OS and major frameworks are the same between development and production, the dependencies may not be the same, causing discrepancies in running the app on the client-side.

Containerizing the application helps resolve this problem.

A common problem and how Docker solves it

Consider a situation where we develop a product using version 1.3 of some software in the development environment and the production environment uses version 1 of the same software. We can’t guarantee that our product will work in the exact same way in both environments since there is a version mismatch.

Version upgrades of packages are usually done to increase security, fix vulnerabilities and bugs, provide new features, and so on. Though this seems fine, sometimes the newer version uses a different type of command than the older version. This kind of problem arises with version incompatibilities and many other situations related to version changes.

Containerization solves this problem.

Docker helps containerize the whole product or app and installs all the necessary dependencies in the container so that we can ensure both the development and production environment have the same resources.

By containerizing, you can stop worrying about version changes and compatibility issues from development to production.

How is Docker different from virtual machines?

Virtual machines were one of the earlier methods of solving the problem of environmental mismatch between development and production. They had an individual OS, but it led to unwanted and unutilized memory and resources.

Virtual machines are huge in size; you have a separate OS running on an OS. On the other hand, Docker containers help us choose the OS kernel we are building upon.

Imagine you have a computer with an app running on it. Running a single app inside a VM on this computer instead is not a better use of resources. We cannot run multiple apps since the purpose of a VM is to provide the dependencies and everything specific to the app. Running multiple apps will again be of the same problem which involves version changes and so on.

A container solves this problem as it is an independent entity that needs nothing more. Multiple containers can be run on a machine depending upon resource utilization, overcoming the resource issues with VMs.

How does Docker create containers?

Docker takes the application and creates an image from it. This is an important feature in transporting large apps, where just the running instance of the image acts as a container. A Docker image is usually smaller than a VM.

In short, we will use a file called a Dockerfile where you can specify everything the app needs, starting from the OS; passing arguments on build time, copying, or storing contents to a different folder; package installation; and so on.

This Dockerfile should be able to build the image of the app, and this image will be run as Docker containers. This image will then be used in pipelines for CI/CD integrations and final deployments.

DockerHub and existing images

DockerHub is a container library with thousands of existing images. We can use these images as base images that our apps can be built on top of. Some of the available images are Nginx, Node, and other popular technologies. We can choose a base image depending on our requirements.

Providing images of an app is also becoming a standard way of distributing a product to end-users.

Other benefits of containers

If we were to get more traffic to our containerized app, scaling up is simple. All we have to do is increase the number of containers. Though this begins to involve more advanced concepts, increasing the number of containers is generally what happens.

With an image, rolling back to a previous image version is simple as well. This helps revert any breaking changes that happened in the last commit.

Images are fast, and we can exactly optimize them as required. There are a lot of Docker base images that are very small, like Alpine which has an image size of less than 4 MB. Building our app on top of these small base images helps optimize the final size of the image without limiting the app’s behavior.

Conclusion

Docker is a tool that helps containerize applications. Containers have become one of the most effective ways to deploy apps since they are fast, reliable, and reduced in size. Docker containers are created through Docker images which provide different snapshots of the image at different times in its development. Having such snapshots can be of great help in the long run. When a commit breaks something, we can easily revert the deployment to an older snapshot and resolve the issue.

Thank you for reading!

Syncfusion has over 1,700 components and frameworks for WinForms, WPF, WinUI, .NET MAUI (Preview), ASP.NET (Web Forms, MVC, Core), UWP, Xamarin, Flutter, JavaScript, Angular, Blazor, Vue, and React. Use them to boost your application development speed.

For current customers, the new Essential Studio version is available for download from the License and Downloads page. If you are not yet a Syncfusion customer, you can try our 30-day free trial to check out our newest features.

If you have questions, you can reach us through our support forums, support portal, or feedback portal. As always, we are happy to assist you!

Related articles

Top comments (0)