2.9. Docker Hello World

发布时间 :2025-10-25 12:31:05 UTC      

Docker allows you to run applications within a container, using the docker run Command to run an application within the container.

Output Hello world

runoob@runoob:~$ docker run ubuntu:15.10 /bin/echo "Hello world"
Hello world

Image0

Each parameter is resolved:

  • docker: The binary execution file for Docker.

  • run: Combine with the previous docker to run a container.

  • ubuntu:15.10 Specify the image to run. Docker first looks up whether the image exists on the local host. If it does not exist, Docker downloads the public image from the image repository Docker Hub.

  • /bin/echo “Hello world”: Commands executed in the startup container

The complete meaning of the above command can be interpreted as: Docker creates a new container in the ubuntu15.10 image, then executes bin/echo “Hello world” in the container, and then outputs the result.

2.9.1. Run an interactive container

We let the container that docker runs implement through the two parameters of docker-I-t. “对话” Ability to:

runoob@runoob:~$ docker run -i -t ubuntu:15.10 /bin/bash
root@0123ce188bd8:/#

Each parameter is resolved:

  • -t: Specify a pseudo terminal or terminal in the new container.

  • -i: Allows you to interact with standard input (STDIN) within the container.

Notice the second line root @ 0123ce188bd8 :/#, at this point we have entered a container for the ubuntu15.10 system

We try to run the command in the container cat /proc/version And ls View the version information of the current system and the list of files in the current directory respectively

root@0123ce188bd8:/#  cat /proc/version
Linux version 4.4.0-151-generic (buildd@lgw01-amd64-043) (gcc version 5.4.0 20160609 (Ubuntu 5.4.0-6ubuntu1~16.04.10) ) #178-Ubuntu SMP Tue Jun 11 08:30:22 UTC 2019
root@0123ce188bd8:/# ls
bin  boot  dev  etc  home  lib  lib64  media  mnt  opt  proc  root  run  sbin  srv  sys  tmp  usr  var
root@0123ce188bd8:/#

We can exit the container by running the exit command or by using CTRL+D.

root@0123ce188bd8:/#  exit
exit
root@runoob:~#

Notice in the third line that root @ runoob :~# indicates that we have exited the current container and returned to the current host.

2.9.2. Start the container (background mode)

Use the following command to create a container that runs as a process

runoob@runoob:~$ docker run -d ubuntu:15.10 /bin/sh -c "while true; do echo hello world; sleep 1; done"
2b1b7a428627c51ab8810d541d759f072b4fc75487eed05812646b8534a2fe63

In the output, we do not see the expected “hello world”, but a string of long characters

2b1b7a428627c51ab8810d541d759f072b4fc75487eed05812646b8534a2fe63

这个长字符串叫做容器 ID,对每个容器来说都是唯一的,我们可以通过容器 ID 来查看对应的容器发生了什么。

First, we need to make sure that the container is running and can be accessed through the docker ps To see:

runoob@runoob:~$ docker ps
CONTAINER ID        IMAGE                  COMMAND              ...
5917eac21c36        ubuntu:15.10           "/bin/sh -c 'while t…"    ...

Description of output details:

CONTAINER ID: Container ID.

IMAGE: The mirror image used.

COMMAND: The command that runs when the container is started.

CREATED: The time when the container was created.

STATUS: Container status.

There are 7 states:

  • Created (created)

  • Restarting (restarting)

  • Running or Up (running)

  • Removing (migrating)

  • Paused (pause)

  • Exited (stop)

  • Dead (death)

PORTS: The port information of the container and the connection type used (tcpudp).

NAMES: The container name that is automatically assigned.

Use the docker logs command within the host host to view the standard output within the container:

runoob@runoob:~$ docker logs 2b1b7a428627

Image1

runoob@runoob:~$ docker logs amazing_cori

Image2

2.9.3. Stop the container

We use docker stop Command to stop the container:

Image3

Through the docker ps view, the container has stopped working:

runoob@runoob:~$ docker ps

You can see that the container is gone.

You can also stop it with the following command:

runoob@runoob:~$ docker stop amazing_cori
Principles, Technologies, and Methods of Geographic Information Systems  102

In recent years, Geographic Information Systems (GIS) have undergone rapid development in both theoretical and practical dimensions. GIS has been widely applied for modeling and decision-making support across various fields such as urban management, regional planning, and environmental remediation, establishing geographic information as a vital component of the information era. The introduction of the “Digital Earth” concept has further accelerated the advancement of GIS, which serves as its technical foundation. Concurrently, scholars have been dedicated to theoretical research in areas like spatial cognition, spatial data uncertainty, and the formalization of spatial relationships. This reflects the dual nature of GIS as both an applied technology and an academic discipline, with the two aspects forming a mutually reinforcing cycle of progress.