Quickly understand what is: Docker

Docker, a tool that packages software into containers and runs reliably in any environment. But what are containers and why are they needed? Let’s learn how to quickly get started with Docker today! Hope this article is helpful to you.

Let's say you use Cobol to build an application that runs on some weird flavor of Linux. You want to share this app with your friend, but he has a completely different system. The question then becomes, how do we replicate the environment our software requires on any machine?

One way to package an application is to use a virtual machine, where you emulate the hardware and then install the required operating system and dependencies.

This allows us to run multiple applications on the same infrastructure. However, since each virtual machine runs its own operating system, they tend to be large and slow.

Now, Docker containers are conceptually very similar to virtual machines, but there is one key difference.

Containers only virtualize the operating system, not the hardware. Or in other words, all applications or containers are run by a single core, which makes almost everything faster and more efficient.

Three basic elements.

The world of Docker consists of three basic elements:

  • Dockerfile
  • mirror
  • container

Dockerfile is like DNA. It's just code that tells Docker how to build the image. The image itself is a snapshot of the software, along with all dependencies all the way down to the operating system level. The image is immutable and it can be used to launch multiple containers, which is the actual software you run in the real world.

Create a docker file and start from an existing template (such as Ubuntu) using from.

The base image is downloaded from the cloud, and you can also upload your own images to various Docker registries.

From there, you may need to use run to run the terminal command that installs the dependencies into the image. You can set environment variables and perform various other operations, and then the last thing you want to do is set the default command that is executed when starting the container.

Now, we can create the image file by running the docker build command.

It goes through each step in the Dockerfile to build the image layer by layer.

We can then use the docker run command to bring this image to life as a container.

Since your application requires more resources, you can run it on multiple computers, multiple clouds, on-premises, or wherever you want it to be reliable.

Finally, I picked up an introductory course on Docker. If you want to learn more, you can follow my official account: Programmer DD, send the password: docker, and get the download address.

If you want to broaden your horizons and understand and discover more concepts and knowledge in the computer field, welcome to follow my continuously updated developer science column to help you explore more popular knowledge in the computer field!

Welcome to follow my public account: Programmer DD. If we had known about cutting-edge technology, there would be hope for overtaking on curves! To accumulate overtaking capital, start by paying attention to DD!

Guess you like

Origin blog.csdn.net/dyc87112/article/details/134865730