Docker Tutorial on Real-World Examples

(27)

Nikita Buinitsky
Author, Geomotiv
Published: Mar 8, 2019

What is a software container? As its glass fellow, it stores things. In our case, it stores code, libraries, configuration files, etc. Containers are safe and scalable, when talking about software development, and quite easy to use. To work with it properly, to develop and launch applications, one will require special software. This soft allows operating-system-level virtualization. Otherwise known as containerization. Docker is one of the most popular tools for it.

A traditional glass container.

Advantages of Docker Container

Pushing further the analogy with a glass package, let’s dig into a Docker container essence:

  • It was made to store stuff. As its glass fellow, a Docker container stores things and keeps them ready to use anytime. 
  • It is light. A Docker container weights only tens of MBs. So you don’t need to wait long until it downloads to a cloud server. 
  • Containers are standard. New tendencies in glass containers making are unlikely to appear. The same goes for software containers as Docker has determined their shape. Now they are standard and thus quite portable. 
  • Containers are user-friendly. Glass jars are easy to use as they have the main part and a cover. Docker containers have understandable interface as well. It is simple for new users to study out. 
  • Works wherever you like. You can take it to any place and make it work everywhere. It can be on your own PC, on your neighbor’s one, or on a cloud service such as Microsoft Azure. Moreover, you can move your container to other Docker environment without difficulties within one OS.
  • It is safe. It is safer to run an app in an isolated container. Docker on default allows developers to use its isolating potential on the whole. 

Docker Container as a Program

A Docker container may also appear as a program or, to be exact, as a set of instructions managing parts of app mechanisms. In such a manner, a particular program operates within a container, allowing for sending pieces of pages content you are surfing right now or decoding your commands in order to use them in another Docker. 

A symbol of Docker.

What is more, it allows for running several containers at once using a single Docker. No mess up with masses of programs. Anyway, you can make your Docker list containers that you have. Likewise you can even make your Docker remove all containers. Like any other program, it supports all the basic functions and commands.

Docker Image vs Container

Two the most basic things you come across when using Docker are Image and Container. If a container appears to be more or less clear, an image needs some explanation. In general, a Docker image is a set of layers that serve for code execution in a Docker container. In other words, it is a template for running your containers. With it you can have a number of them based on a single image. 

An image comprises a Docker file, system libraries, dependencies, tools, and settings. These building blocks are important for running Docker itself. It is based on the OS kernel and most often it is Linux or Windows. Along with a Docker Windows container, you can have a Docker image for any OS as well.

Creating a Docker Container

To use a container, it is good to create it at first. Let’s have another analogy for better understanding. All in all, the process of making a container somehow reminds of a layer cake. So we will use this idea and see “container baking” from the inside.

Your potential result.

Here are the Steps and Main Points of Creating a Container:

  • At first, you will need a Dockerfile. It is a text file with a set of commands. This file is needed for performing the creation of a container. Let it be a cake recipe in our case. It contains explanations of layer usage, such as libraries and so on. 
  • A recipe and ingredients (code or various settings) together compose a Docker image. In our example, a Docker image is the dough. It can be used to bake a number of cakes. Just imagine that your dough is limitless.
  • Then comes icing. It is libraries that we implement for work. The main difference from real life here is that you should put icing before baking.
  • Don’t forget about filling. It is the code you’ve written for your application. It is the main part of an app. Without filling you will get a dry and tasteless cake.

So, the preparation phase is over. Now it is time to bake.

The oven you may use.

Time to "Bake":

  • As you have already installed your oven, you should run it. By the oven we mean a Docker platform that can be downloaded. To do so open your command line and write “docker run”. It’s the same as igniting the oven.
  • Your cake will be ready in a few minutes. The delicious baked cake is your Docker container
  • The final stage is eating your cake. It is the usage of your application. The easiest and most pleasant part of the process.
  • Still, you can always put the cake in the freezer. Just make your docker stop container in order to use it later.

Conclusion

It takes time and effort to create a container. But ultimately you will get a tool for easier work with applications. Additionally, it will bring a great possibility to develop them in isolation from the system.

SHARE THIS ARTICLE

Blog

Recommended Reading

Monolithic apps seem to lose their popularity in contrast to microservices, which all...

DevOps is a methodology that helps to establish interaction between developers and op...

Our guide will give you step-by-step instructions on how to integrate your Magento...

The food delivery segment received a huge boost for its development amid the...

In 2020, both educational institutions and students faced the situation when the digi...

In the context of lockdowns, online platforms became the only possible solution for.....

01
/
05