2.30. Docker run command

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

Docker 命令大全

docker run : Create a new container and run a command

2.30.1. Grammar

docker run [OPTIONS] IMAGE [COMMAND] [ARG...]

OPTIONS description:

  • -a stdin: Specifies the standard input and output content type, with three optional STDIN/STDOUT/STDERR items

  • -d: Run the container in the background and return the container ID

  • -i: Runs the container in interactive mode, usually in conjunction with-t

  • -P: Random port mapping, container internal port 随机 Port mapped to the host

  • -p: Specify port mapping. Format: host (host) port: container port

  • -t: Reassign a pseudo-input terminal to the container, usually used with-I

  • –name=”nginx-lb”: Specify a name for the container

  • –dns 8.8.8.8: Specifies the DNS server used by the container, which is the same as the host by default

  • –dns-search example.com: Specifies the container DNS search domain name, which is the same as the host by default

  • -h “mars”: Specify the hostname of the container

  • -e username=”ritchie”: Set environment variabl

  • –env-file=[]: Read environment variables from the specified file

  • –cpuset=”0-2” or –cpuset=”0,1,2”: Bind the container to the specified CPU run

  • -m : Set the maximum memory used by the container

  • –net=”bridge”: Specifies the network connection type of the container, which supports bridge/host/none/container: four types

  • –link=[]: Add a link to another container

  • –expose=[]: Open a port or group of ports

  • –volume , -v: Bind a volume

2.30.2. Example

Use the docker mirror nginx:latest to start a container in background mode and name the container mynginx.

docker run --name mynginx -d nginx:latest

Use mirrored nginx:latest to start a container in background mode and map the container’s port 80 to the host random port.

docker run -P -d nginx:latest

Using mirror nginx:latest, start a container in background mode, mapping port 80 of the container to port 80 of the host, and the directory / data of the host to the / data of the container.

docker run -p 80:80 -v /data:/data -d nginx:latest

Bind port 8080 of the container and map it to port 80 of the local host 127.0.0.1.

$ docker run -p 127.0.0.1:80:8080/tcp ubuntu bash

Use the mirror nginx:latest to start a container in interactive mode and execute the / bin/bash command inside the container.

runoob@runoob:~$ docker run -it nginx:latest /bin/bash
root@b8573233d675:/#

Docker 命令大全

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.