Hello everyone, I changed the theme of my site and added a few components. I noticed one thing, I’ve been blogging for a few years, but when I looked at the archive section of my blog, I shared almost only one article in the remaining months, except for a few months. I’m thinking; I must have blogged more than one post per month. But in reality it wasn’t. Anyway, this reminded me nicely that I need to focus more on the blog. Now I plan to share at least one post a week. Let’s get back to our topic then.
What is Docker?
Actually, docker is not a new technology. It’s a system that has been around for years. And it has a structure that allows application developers or users who know a little more application infrastructures to run applications smoothly on every platform.
So what is this docker? We can define Docker as a virtual machine in its simplest form. Any application you install on the virtual machine will run independently of your operating system and contain application dependencies. Thus, you can install and run any application you want in isolation from your operating system. I will explain it in more detail in the following sections.
Let’s open the subject a little more with an example on the Linux operating system.
Now let’s imagine that we are going to develop an application with python. While developing this application, we may need to use third-party modules depending on what we want to do. These are addictions. These dependencies have to be in our system. If we do not install these dependencies on the operating system, we cannot develop applications. We provided the dependencies and completed our implementation. It works great, just the way we wanted it. Now we wanted to share this application with a friend and we sent the application codes to our friend, we assume that our friend has a linux operating system. Our friend took these codes and tried to run the application without installing the dependencies required for our application to work. In such a case, the application we wrote will not work. Our friend will have to install dependencies. Our friend saw the dependencies required for the application to work and understood that the application would not work without installing them, so he started searching the internet to install the dependencies of the application we wrote and found the necessary dependencies and installed them. For this, he had to do some research and spend time. Now when he tried to run the application again, he encountered a different error and could not run the application. Then he did some more research on the internet and saw the problem with the dependencies of the application he wanted to run on the operating system he was using. And it stopped running the app.
In such a scenario, we can put ourselves in our friend’s place. This is truly an infuriating situation. Many such scenarios can be encountered.
I want to give an example from myself. I wrote an application that sends messages over telegram with Python. The purpose of the application is to receive the works that I filtered through upwork and save these works to the database. Then send it to me via telegram at the interval I set. This application worked on my computer without any problems, but for this application to function, it must be constantly active. For this, I need to send this application to a server and run it there. For this, I opened an account on pythonanywhere and started running the application there. I encountered a lot of errors when I wanted to install the dependencies of the application and I really spent a lot of time on forum sites to solve it.
Let’s continue with one more example; Apart from what I wrote, you may want to test your application on different platforms. For performance or for other purposes. In such a case, you need to install the operating system you want to test on your computer, and then install your application and perform the test. This causes you to spend too much time and energy.
Here’s what I wrote at length and for many more reasons that I can’t think of, you can quickly compile, test and deploy your applications using docker.
We named Docker as a virtual machine for short. Now let’s open the subject a little more and see what kind of structure it is.
Docker; packages the software with all the necessary functions in standardized units called “containers”. You can create these packages at any time by adding the applications you want. These packages you have created are called images.
If we examine what happened to me with docker now; If I had imaged my application with docker, all the dependencies I wrote would be inside this image and I would send this image to any server I wanted and run my application regardless of the operating system of the server I sent. Thus, I would not have to spend time on problems caused by operating system differences.
Docker allows to run these created images. You can create these images as you wish. For example; I have developed an application with python and I just want to use python. In such a case, it is sufficient to have the python interpreter and the program we need, as well as the dependencies required for the application. We don’t need any other app. We create the image by writing all these variables into a text file called “Docker file” and start using it. A docker image can be created for each application. There are no limits. In addition, we can use docker images created by other people by downloading them. There is a website created for this. On this website, we can download and use the docker image created by someone else according to our needs. Or we can send the image we created to this site and make it available to others.
In order to run these created docker images, we need docker installed on our system. For Docker installation, you can follow the instructions on its site.
What to do with Docker?
I will try to explain this with examples. I assume you have no programming knowledge. You found an application code and you want to try it, but the application requires a lot of dependencies to try. You do not want to install unfamiliar applications and dependencies on your operating system. For this, you can make the application you want to use as an image with docker so that it works independently of your operating system and sees the result.
Another example; You have found an application and it only works within the linux operating system. You are using windows. To run this application on windows, you need to make changes to the application. You have no idea about it. In such a case, by creating a docker image, you create an image by throwing linux and the application you want into it, and if you run this image on windows, you can use it without any problems.
I used the last example I gave. I talked to a customer on Fiverr and he asked me to make an application, I completed the application and showed it by shooting a video. He liked it and asked me to submit the app. I sent the application. He said the app gave an error on his own computer. I am using linux and he wanted to use this application on windows. As in the examples I gave above, errors occurred due to the operating system. Then I imaged the application I wrote using docker and sent it. All the customer has to do is download the image and run it. I made the necessary settings for the application to run automatically in the image. The client just downloaded and ran the image and used the desired application without any problems.
Actually, docker is not a topic to be explained with such a blog post. There are many topics such as how to create an image for Docker, what operations are performed in the created image, how to prepare the “Docker file” used to create the image. I just wanted to make it simple by giving examples for those who have never heard of this subject. I hope it has been enlightening for those who don’t know. Hope to see you in my next article…
I’m thinking of publishing a blog post every Monday now, this is my first post
This article was first published on the website www.kenanyaman.com on 14 jun 2021.