Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

10 minutes to learn docker

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

This article takes about 10 minutes.

You will see the following:

Why use dockerdocker concepts such as how to run docker container and how to build image

This article assumes that you have the following foundation:

1.linux command line (see reference link)

two。 Necessary English vocabulary

Why use docker?

When discussing the benefits that docker can bring to us, we first need to understand what docker is. The official website of docker describes it as "Docker is the world's leading software container platform." It can be seen that docker is a container platform, we put the things to be packaged in a container, and then we can run on the docker platform, because docker can be installed on each system, so it can be system-independent, shielding the complexity of the environment. At the same time, docker's container can contain all the dependencies on which app is running, so there is no need to install all dependencies manually at deployment time.

What are the core concepts in docker

Although the concept is like a textbook at first, if you don't understand the core concept, you may not understand the following things. Or skip here and look directly below, and look back if you encounter something you don't understand.

Image and container

Image contains the code, dependency, and runtime of an application. Container can be understood as the running form of image, which exists as an independent process.

Docker deamon and docker client

Daemon of docker, back-end service. Docker client is a client of docker that interacts with docker deamon.

Base image and child image

Base image refers to mirrors that do not have parent images, which are generally system-level mirrors, such as ubuntu,alpine. The image that child image built on base image.

Description file for Dockerfile image. It contains all the information you need to run app. Including base image, code location, working directory, dependencies, project startup commands, and so on.

How to run docker container

There is no need to elaborate on the installation of docker, you can go to the reference link.

Execute your first docker statement first

Docker container run hello-world

Hello world,so cool,right again?

Unable to find image 'hello-world:latest' locally latest: Pulling from library/hello-world 03f4658f8b78: Pull complete a3ed95caeb02: Pull complete Digest: sha256:8be990ef2aeb16dbcb9271ddfe2610fa6658d13f6dfb8bc72074cc1ca36966a7 Status: Downloaded newer image for hello-world:latest

Hello from Docker. This message shows that your installation appears to be working correctly.

If you can see the above, it proves that you have run the first docker container. Congratulations.

Let's see what happens after that command is run. First of all, docker will go to your local to find out if there is a hello-world image, and then it will go to docker registry to find out if there is a hello-world. After finding it, it will pull it to the local place, and then it will find that there is a dependency in it. It will then pull the dependency. Finally, it will pull successfully and start.

All right, remove the container that is no longer needed. Run the following statement

Docker container ls-a

You'll see what's down there.

CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 9e354503933b hello-world "/ hello" 4 minutes ago Exited (0) 27 seconds ago serene_engelbart

Copy all or part of the container id

Running the following statement will remove container

Docker container rm-f 9e354503933b

It is not enough to remove container, container is just running form, image is still there, and image has to be removed. Run the following statement to list your local images.

Docker images

You will receive a corresponding image id, and then remove the image via image id.

Docker image rm 1815c82652c0

How to build docker image

That's all for today. We'll talk about the following article next time. Hey.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report