docker run -d -p what does it mean

下次还敢
Release: 2024-04-02 22:30:18
Original
1023 people have browsed it

The docker run -d -p command is used to run the container, run it in daemon mode (-d) and map the port (-p), allowing external access to services within the container.

docker run -d -p what does it mean

The meaning of docker run -d -p

docker run -d -p The command is used to run the container in Docker and specifies the following parameters:

  • -d: Run the container in daemon mode. After the container is started, it will run in the background, even if the terminal exits. stop.
  • -p: Port mapping, mapping the internal port of the container to the external port of the host so that the outside world can access the services in the container.

Usage Example

The following is an example of using the docker run -d -p command to run an Nginx container:

<code class="shell">docker run -d -p 80:80 nginx</code>
Copy after login

In this example:

  • -p 80:80 specifies that port 80 inside the container is mapped to port 80 outside the host.
  • After running this command, the container will start and run the Nginx web server in the background. External users can access the Nginx service through port 80 on the host.

Parameter description

  • -p The option is followed by two parameters, separated by a colon (:):

    • Container port: The port number to be exposed inside the container.
    • Host port: The host external port number to which the container port is mapped.
  • You can specify multiple port mappings, each mapping separated by commas.
  • The host port can be omitted, in which case Docker will automatically assign a random available port.

The above is the detailed content of docker run -d -p what does it mean. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template