How correction in stock market can be good for your investments?

The recent market volatility has been sending jitters to the investors and many of them are making hasty moves and losing their hard earned money in the process. However, contrary to what you may…

Smartphone

独家优惠奖金 100% 高达 1 BTC + 180 免费旋转




What in the World is Docker?

Understand the basics of Docker and its real-world applications.

Developing applications and deploying them in production is still a time-consuming and complex thing to do as a developer. We need to set all the dependencies, packages, libraries onto the server. The server may have some other OS and we need to build each dependency that is server-specific to run our application. Just by reading this, we get to know that this is a tedious process and requires a lot of time and energy just to set up the server to run our application. So, to avoid such work, Docker was released to ease the process. Docker uses a concept called Containerization, which makes the deployment process effortless.

Let’s take a look at the contents that we will cover in this article.

Docker is a set of Platform As A Service (PaaS) products that use OS-level virtualization to deliver software in packages called containers. Containers are isolated from one another and bundle their own software, libraries, and configuration files; they can communicate with each other through well-defined channels. Because all of the containers share the services of a single operating system kernel, they use fewer resources than virtual machines. The software that hosts these containers is called Docker Engine. Docker includes components such as Docker Client, Docker Server, Docker Machine, Docker Hub, Docker Composes, and more.

Docker benefits both Developers and System Admins. It eradicates the machine-specific problem like “Code runs on one PC but not on the other”. Enterprises use Docker to securely built agile software delivery pipelines to ship new application features faster and more securely. It can not only be used for deployment but also for the development process, which makes it more scalable and robust.

Note: You need to login into the docker hub account and then search for your images.

Docker Containers are the lightweight alternatives of the virtual machine. It allows developers to package up the application with all its libraries and dependencies, and ship it as a single package. The best thing Docker offers you is you need not provide any space for storage or allocate any RAM for your application. It will automatically generate storage and space according to the application and its requirements. It does not require any hypervisor as the virtual machine does. Which makes it more scalable and fast.

Whereas a Virtual Machine is a virtual representation of a physical computer. They are referred to as guest machines that use our local hardware to function. Virtualization is the process of creating multiple virtual machines, each with its own operating system (OS) on a single physical machine. A VM cannot interact directly with a physical computer. Instead, it needs a lightweight software layer called a hypervisor to coordinate between it and the underlying physical hardware. The hypervisor allocates physical computing resources such as processors, memory, and storage to each VM. It keeps each VM separate from others so they don’t interfere with each other.

Let’s get our hands dirty as always and start implementing docker.

Note: In this article, we use a Linux-based OS i.e, Ubuntu to run docker because it is easy and fast in Linux-based systems.

Now let us open our terminal and update your apt packages first using the following and install snap too.

That’s it for the prerequisite though. Now let’s install docker using snap.

Done. That’s right. We just installed docker in our Ubuntu. That was pretty easy, right?

Now we’ll see some docker commands that will be useful in the long run.

Note: make sure you use sudo before any docker command or else it won't execute in Ubuntu.

Go ahead and create your Dockerfile and pull the existing image from the Docker Hub. After pulling python image from Docker Hub go ahead and install NumPy or any other import you want. As this is an example of how Docker works so let us stick with simplicity here.

Dockerfile

we import or pull the existing Python Docker Image from Docker Hub.

Add our existing working directory to the new directory /code inside the Docker Container.

Use the RUN command to run any terminal-specific commands like installing numpy using pip.

This CMD command is used to run the python command on the Docker terminal. Specify the command that is python to run any python file and the file itself to execute here it is main.py

That’s it, our Docker is set and all we have to do now is create your main.py where you use some NumPy operation (as for this example) or any other operations of your choice.

main.py

Finally, build and run your Docker container using the following command

Build

Run

That’s it. If your installing and setup was perfect then you should see output saying the following

Congratulations! you have successfully set up your docker station and now it is up to your applications to deploy using docker.

In this article, we have seen a detailed introduction about Docker and its uses in real-world applications. We understood the concept of containerization and also to demonstrate its functionality, we have implemented a simple Docker application. So, go ahead and discover new wonders with Docker. I hope this article was useful to you all. Will see you in my next article until then as always code learn repeat …….

Follow for more…

Add a comment

Related posts:

Your Faith

There is a problem around faith. That problem is the religious drift in the vast ocean of the spiritual being that we are, whatever form we decide to print on it. Religiosity is dual, meaning that…

What Filmmaking Means to Me

On my last day of school, I had an unexpectedly memorable conversation with a friend. He was the only person who didn’t stare back at me in shock upon hearing that I was leaving school to restore my…

Is Asteroid Apophis a Risk to Earth?

NASA scientists have decided that the dangerous asteroid Apophis will not come within a dangerous distance of Earth for at least the next hundred years. Named after the ancient Egyptian God of…