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

How to run the docker container

2025-04-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

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

This article introduces the knowledge of "how to run the docker container". Many people will encounter this dilemma in the operation of actual cases, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

First, let's take a look at the current local docker image:

[root@xinsz10 ~] # docker images

REPOSITORY TAG IMAGE ID CREATED SIZE

You can see that there are currently no mirrors, and then we execute the second command to pull a hello-world image

[root@xinsz10 ~] # docker pull hello-world

Using default tag: latest

# is equivalent to adding a latest to our helloworld.

Latest: Pulling from library/hello-world

# pulling a hello-world under library

Digest: sha256:b2ba691d8aac9e5ac3644c0788e3d3823f9e97f757f01d2ddc6eb5458df9d801

Status: Image is up to date for hello-world:latest

To see if the download is complete, that is, to view the local image

[root@xinsz10 ~] # docker images

REPOSITORY TAG IMAGE ID CREATED SIZE

Hello-world latest 05a3bd381fc2 4 weeks ago 1.84kB

Note: REPOSITORY is the image name

IMAGE ID is a 64-bit string, which is automatically truncated here and only 16 bits are displayed, which can uniquely identify our image.

CREATED modification time

SIZE Siz

The name of the image can be found on the website. Docker provides an image repository, and hub.docker.com is downloaded here by default.

After the image download is complete, let's see how to run it.

Specific command: docker run + option IMAGE [: TAG] [command] [ARG..]

[root@xinsz10 ~] # docker run hello-world

WARNING: IPv4 forwarding is disabled. Networking will not work.

Hello from Docker!

This message shows that your installation appears to be working correctly. # if this message is displayed, your installation is already OK

The following steps in English tell us which steps docker has gone through when it runs

To generate this message, Docker took the following steps:

1. The Docker client contacted the Docker daemon.

2. The Docker daemon pulled the "hello-world" image from the Docker Hub.

3. The Docker daemon created a new container from that image which runs the

Executable that produces the output you are currently reading.

4. The Docker daemon streamed that output to the Docker client, which sent it

To your terminal.

To try something more ambitious, you can run an Ubuntu container with:

$docker run-it ubuntu bash

Share images, automate workflows, and more with a free Docker ID:

Https://cloud.docker.com/

For more examples and ideas, visit:

Https://docs.docker.com/engine/userguide/

According to the English prompt that pops up above, (about what docker does when performing docker run)

Let's use a diagram to look at the whole process of docker pull and docker run:

The two on the left are running locally, and the rightmost is the remote mirror.

Docker pull checks whether the image exists in the native images. If it exists and the version is correct, use it directly. If it does not exist, download it from the docker repository and use it.

The same is true of docker run. When you execute this command, you also need to go to the local images to check whether it exists. If it does not exist, it will pull the image from the remote end just like docker pull.

This is the end of how to run the docker Container. Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

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

Internet Technology

Wechat

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

12
Report