Home>Article>Operation and Maintenance> What is run in docker
In docker, run is a command used to create a new container and run a command; when executing "docker run", Docker will start a process and allocate its exclusive files to the process. System, exclusive network resources and process group with this process as the root process, the syntax is "docker run [OPTIONS] IMAGE [COMMAND] [ARG...]".
The operating environment of this tutorial: linux7.3 system, docker version 19.03, Dell G3 computer.
docker run: Create a new container and run a command
Docker will encapsulate related processes into mutually isolated containers when executed ( container). When docker run is executed, Docker will start a process and allocate to this process its exclusive file system, exclusive network resources, and process group with this process as the root process. The Image loaded when Docker starts the container may have a default startup process defined, which requires the exposer's network port and other resources defined in the Dockerfile. But you can redefine this image by default using docker run. This is why the run command has more parameters than other docker command parameters.
Syntax
docker run [OPTIONS] IMAGE [COMMAND] [ARG...]
OPTIONS Description:
docker run --name mynginx -d nginx:latestUse the image nginx:latest to start a container in background mode and map the container's port 80 to a random port on the host.
docker run -P -d nginx:latestUse the image nginx:latest to start a container in background mode, map the container's port 80 to the host's port 80, and map the host's directory /data to the container's /data.
docker run -p 80:80 -v /data:/data -d nginx:latestBind the 8080 port 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 bashRecommended learning: "
docker video tutorial"
The above is the detailed content of What is run in docker. For more information, please follow other related articles on the PHP Chinese website!