mirror of https://github.com/docker/docs.git
Correct parameter names for --publish long syntax (#5457)
This commit is contained in:
parent
b2663493d1
commit
1fa2c0387a
|
@ -1041,7 +1041,7 @@ examples: |-
|
|||
for the same service as above:
|
||||
|
||||
```bash
|
||||
$ docker service create --name my_web --replicas 3 --publish target=8080,port=80 nginx
|
||||
$ docker service create --name my_web --replicas 3 --publish published=8080,target=80 nginx
|
||||
```
|
||||
|
||||
The options you can specify are:
|
||||
|
@ -1063,7 +1063,7 @@ examples: |-
|
|||
<tr>
|
||||
<td>protocol</td>
|
||||
<td><tt>--publish 8080:80</tt></td>
|
||||
<td><tt>--publish target=8080,port=80</tt></td>
|
||||
<td><tt>--publish published=8080,target=80</tt></td>
|
||||
<td><p>
|
||||
The container port to publish and the target port to bind it to on the
|
||||
routing mesh or directly on the node.
|
||||
|
@ -1072,7 +1072,7 @@ examples: |-
|
|||
<tr>
|
||||
<td>mode</td>
|
||||
<td>Not possible to set using short syntax.</td>
|
||||
<td><tt>--publish target=8080,port=80,mode=host</tt></td>
|
||||
<td><tt>--publish published=8080,target=80,mode=host</tt></td>
|
||||
<td><p>
|
||||
The mode to use for binding the port, either `ingress` or `host`. Defaults
|
||||
to `ingress` to use the routing mesh.
|
||||
|
@ -1081,7 +1081,7 @@ examples: |-
|
|||
<tr>
|
||||
<td>protocol</td>
|
||||
<td><tt>--publish 8080:80/tcp</tt></td>
|
||||
<td><tt>--publish target=8080,port=80,protocol=tcp</tt></td>
|
||||
<td><tt>--publish published=8080,target=80,protocol=tcp</tt></td>
|
||||
<td><p>
|
||||
The protocol to use, either `tcp` or `udp`. Defaults to `tcp`. To bind a
|
||||
port for both protocols, specify the `-p` or `--publish` flag twice.
|
||||
|
|
|
@ -1029,7 +1029,7 @@ examples: |-
|
|||
using the `--publish` flag:
|
||||
|
||||
```bash
|
||||
$ docker service create --publish <TARGET-PORT>:<SERVICE-PORT> nginx
|
||||
$ docker service create --publish <PUBLISHED-PORT>:<TARGET-PORT> nginx
|
||||
```
|
||||
|
||||
For example:
|
||||
|
|
|
@ -148,7 +148,7 @@ You can now start creating containers and services.
|
|||
You can run websites too. Ports exposed with `--publish` are automatically exposed
|
||||
through the platform load balancer:
|
||||
|
||||
$ docker service create --name nginx --publish target=80,port=80 nginx
|
||||
$ docker service create --name nginx --publish published=80,target=80 nginx
|
||||
|
||||
Once up, find the `DefaultDNSTarget` output in either the AWS or Azure portals
|
||||
to access the site.
|
||||
|
@ -184,7 +184,7 @@ A good sample app to test deployment of stacks is the [Docker voting app](https:
|
|||
|
||||
By default, apps deployed with stacks do not have ports publicly exposed. Update port mappings for services, and Docker will automatically wire up the underlying platform load balancers:
|
||||
|
||||
docker service update --publish-add target=80,port=80 <example-service>
|
||||
docker service update --publish-add published=80,target=80 <example-service>
|
||||
|
||||
### Images in private repos
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ title: Configure the Docker for AWS load balancer
|
|||
When you create a service, any ports that are exposed with `-p` are automatically exposed through the platform load balancer:
|
||||
|
||||
```bash
|
||||
$ docker service create --name nginx --publish target=80,port=80 nginx
|
||||
$ docker service create --name nginx --publish published=80,target=80 nginx
|
||||
```
|
||||
|
||||
This opens up port 80 on the Elastic Load Balancer (ELB) and direct any traffic
|
||||
|
@ -36,8 +36,8 @@ described in the service label `com.docker.aws.lb.arn`
|
|||
$ docker service create \
|
||||
--name demo \
|
||||
--detach=true \
|
||||
--publish target=80,port=80 \
|
||||
--publish target=443,port=80 \
|
||||
--publish published=80,target=80 \
|
||||
--publish published=443,target=80 \
|
||||
--label com.docker.aws.lb.arn="arn:aws:acm:us-east-1:0123456789:certificate/c02117b6-2b5f-4507-8115-87726f4ab963" \
|
||||
yourname/your-image:latest
|
||||
```
|
||||
|
@ -70,8 +70,8 @@ Listen for HTTP on ports 80 and HTTPS on 444
|
|||
$ docker service create \
|
||||
--name demo \
|
||||
--detach=true \
|
||||
--publish target=80,port=80 \
|
||||
--publish target=444,port=80 \
|
||||
--publish published=80,target=80 \
|
||||
--publish published=444,target=80 \
|
||||
--label com.docker.aws.lb.arn="arn:aws:acm:us-east-1:0123456789:certificate/c02117b6-2b5f-4507-8115-87726f4ab963@444" \
|
||||
yourname/your-image:latest
|
||||
```
|
||||
|
@ -82,8 +82,8 @@ $ docker service create \
|
|||
$ docker service create \
|
||||
--name demo \
|
||||
--detach=true \
|
||||
--publish target=80,port=80 \
|
||||
--publish target=444,port=80 \
|
||||
--publish published=80,target=80 \
|
||||
--publish published=444,target=80 \
|
||||
--label com.docker.aws.lb.arn="arn:aws:acm:us-east-1:0123456789:certificate/c02117b6-2b5f-4507-8115-87726f4ab963@443,444" \
|
||||
yourname/your-image:latest
|
||||
```
|
||||
|
@ -94,7 +94,7 @@ $ docker service create \
|
|||
$ docker service create \
|
||||
--name demo \
|
||||
--detach=true \
|
||||
--publish target=8080,port=80 \
|
||||
--publish published=8080,target=80 \
|
||||
--label com.docker.aws.lb.arn="arn:aws:acm:us-east-1:0123456789:certificate/c02117b6-2b5f-4507-8115-87726f4ab963@8080" \
|
||||
yourname/your-image:latest
|
||||
```
|
||||
|
|
|
@ -131,7 +131,7 @@ You can now start creating containers and services.
|
|||
|
||||
You can run websites too. Ports exposed with `--publish` are automatically exposed through the platform load balancer:
|
||||
|
||||
$ docker service create --name nginx --publish target=80,port=80 nginx
|
||||
$ docker service create --name nginx --publish published=80,target=80 nginx
|
||||
|
||||
Once up, find the `DefaultDNSTarget` output in either the AWS or Azure portals to access the site.
|
||||
|
||||
|
@ -161,7 +161,7 @@ A good sample app to test deployment of stacks is the [Docker voting app](https:
|
|||
|
||||
By default, apps deployed with stacks do not have ports publicly exposed. Update port mappings for services, and Docker will automatically wire up the underlying platform load balancers:
|
||||
|
||||
docker service update --publish-add target=80,port=80 <example-service>
|
||||
docker service update --publish-add published=80,target=80 <example-service>
|
||||
|
||||
### Images in private repos
|
||||
|
||||
|
|
|
@ -200,7 +200,7 @@ Next, start a single-replica Prometheus service using this configuration.
|
|||
```bash
|
||||
$ docker service create --replicas 1 --name my-prometheus \
|
||||
--mount type=bind,source=/tmp/prometheus.yml,destination=/etc/prometheus/prometheus.yml \
|
||||
--publish target=9090,port=9090,protocol=tcp \
|
||||
--publish published=9090,target=9090,protocol=tcp \
|
||||
prom/prometheus
|
||||
```
|
||||
|
||||
|
@ -210,7 +210,7 @@ $ docker service create --replicas 1 --name my-prometheus \
|
|||
```bash
|
||||
$ docker service create --replicas 1 --name my-prometheus \
|
||||
--mount type=bind,source=/tmp/prometheus.yml,destination=/etc/prometheus/prometheus.yml \
|
||||
--publish target=9090,port=9090,protocol=tcp \
|
||||
--publish published=9090,target=9090,protocol=tcp \
|
||||
prom/prometheus
|
||||
```
|
||||
|
||||
|
@ -220,7 +220,7 @@ $ docker service create --replicas 1 --name my-prometheus \
|
|||
```powershell
|
||||
PS C:\> docker service create --replicas 1 --name my-prometheus
|
||||
--mount type=bind,source=C:/tmp/prometheus.yml,destination=/etc/prometheus/prometheus.yml
|
||||
--publish target=9090,port=9090,protocol=tcp
|
||||
--publish published=9090,target=9090,protocol=tcp
|
||||
prom/prometheus
|
||||
```
|
||||
|
||||
|
|
|
@ -227,7 +227,7 @@ This example assumes that you have PowerShell installed.
|
|||
```powershell
|
||||
PS> docker service create
|
||||
--name my-iis
|
||||
--publish target=8000,port=8000
|
||||
--publish published=8000,target=8000
|
||||
--config src=homepage,target="\inetpub\wwwroot\index.html"
|
||||
microsoft/iis:nanoserver
|
||||
```
|
||||
|
@ -399,7 +399,7 @@ generate the site key and certificate, name the files `site.key` and
|
|||
--secret site.key \
|
||||
--secret site.crt \
|
||||
--config source=site.conf,target=/etc/nginx/conf.d/site.conf \
|
||||
--publish target=3000,port=443 \
|
||||
--publish published=3000,target=443 \
|
||||
nginx:latest \
|
||||
sh -c "exec nginx -g 'daemon off;'"
|
||||
```
|
||||
|
|
|
@ -25,28 +25,28 @@ service.
|
|||
|
||||
## Publish a port for a service
|
||||
|
||||
Use the `--publish` flag to publish a port when you create a service. The `port`
|
||||
is the port inside the container, and the `target` is the port to bind on the
|
||||
routing mesh. If you leave off the `target` port, a random high-numbered port is
|
||||
Use the `--publish` flag to publish a port when you create a service. `target`
|
||||
is the port inside the container, and `publish` is the port to bind on the
|
||||
routing mesh. If you leave off the `publish` port, a random high-numbered port is
|
||||
bound for each service task. You will need to inspect the task to determine the
|
||||
port.
|
||||
|
||||
```bash
|
||||
$ docker service create \
|
||||
--name <SERVICE-NAME> \
|
||||
--publish target=<PUBLISHED-PORT>,port=<CONTAINER-PORT> \
|
||||
--publish published=<PUBLISHED-PORT>,target=<CONTAINER-PORT> \
|
||||
<IMAGE>
|
||||
```
|
||||
|
||||
> **Note**: The older form of this syntax is a colon-separated string, where
|
||||
> the published port is first and the container port is second, such as
|
||||
> the published port is first and the target port is second, such as
|
||||
> `-p 8080:80`. The new syntax is preferred because it is easier to read and
|
||||
> allows more flexibility.
|
||||
|
||||
The `<CONTAINER-PORT>` is the port where the container listens. If you omit it,
|
||||
a random high-numbered port is bound.
|
||||
The `<PUBLISHED-PORT>` is the port where the swarm makes the service available.
|
||||
This parameter is required.
|
||||
If you omit it, a random high-numbered port is bound.
|
||||
The `<CONTAINER-PORT>` is the port where the container listens. This parameter
|
||||
is required.
|
||||
|
||||
For example, the following command publishes port 80 in the nginx container to
|
||||
port 8080 for any node in the swarm:
|
||||
|
@ -54,7 +54,7 @@ port 8080 for any node in the swarm:
|
|||
```bash
|
||||
$ docker service create \
|
||||
--name my-web \
|
||||
--publish target=8080,port=80 \
|
||||
--publish published=8080,target=80 \
|
||||
--replicas 2 \
|
||||
nginx
|
||||
```
|
||||
|
@ -75,7 +75,7 @@ You can publish a port for an existing service using the following command:
|
|||
|
||||
```bash
|
||||
$ docker service update \
|
||||
--publish-add target=<PUBLISHED-PORT>,port=<CONTAINER-PORT> \
|
||||
--publish-add published=<PUBLISHED-PORT>,target=<CONTAINER-PORT> \
|
||||
<SERVICE>
|
||||
```
|
||||
|
||||
|
@ -107,7 +107,7 @@ the port is published as a TCP port. If you use the longer syntax (recommended
|
|||
|
||||
```bash
|
||||
$ docker service create --name dns-cache \
|
||||
--publish target=53,port=53 \
|
||||
--publish published=53,target=53 \
|
||||
dns-cache
|
||||
```
|
||||
|
||||
|
@ -125,8 +125,8 @@ $ docker service create --name dns-cache \
|
|||
|
||||
```bash
|
||||
$ docker service create --name dns-cache \
|
||||
--publish target=53,port=53 \
|
||||
--publish target=53,port=53,protocol=udp \
|
||||
--publish published=53,target=53 \
|
||||
--publish published=53,target=53,protocol=udp \
|
||||
dns-cache
|
||||
```
|
||||
|
||||
|
@ -145,7 +145,7 @@ $ docker service create --name dns-cache \
|
|||
|
||||
```bash
|
||||
$ docker service create --name dns-cache \
|
||||
--publish target=53,port=53,protocol=udp \
|
||||
--publish published=53,target=53,protocol=udp \
|
||||
dns-cache
|
||||
```
|
||||
|
||||
|
@ -182,7 +182,7 @@ routing mesh is used. The following command creates a global service using
|
|||
|
||||
```bash
|
||||
$ docker service create --name dns-cache \
|
||||
--publish target=53,port=53,protocol=udp,mode=host \
|
||||
--publish published=53,target=53,protocol=udp,mode=host \
|
||||
--mode global \
|
||||
dns-cache
|
||||
```
|
||||
|
|
|
@ -305,7 +305,7 @@ This example assumes that you have PowerShell installed.
|
|||
```powershell
|
||||
PS> docker service create
|
||||
--name my-iis
|
||||
--publish target=8000,port=8000
|
||||
--publish published=8000,target=8000
|
||||
--secret src=homepage,target="\inetpub\wwwroot\index.html"
|
||||
microsoft/iis:nanoserver
|
||||
```
|
||||
|
@ -497,7 +497,7 @@ generate the site key and certificate, name the files `site.key` and
|
|||
--secret site.key \
|
||||
--secret site.crt \
|
||||
--secret source=site.conf,target=/etc/nginx/conf.d/site.conf \
|
||||
--publish target=3000,port=443 \
|
||||
--publish published=3000,target=443 \
|
||||
nginx:latest \
|
||||
sh -c "exec nginx -g 'daemon off;'"
|
||||
```
|
||||
|
@ -510,7 +510,7 @@ generate the site key and certificate, name the files `site.key` and
|
|||
--secret site.key \
|
||||
--secret site.crt \
|
||||
--secret site.conf \
|
||||
--publish target=3000,port=443 \
|
||||
--publish published=3000,target=443 \
|
||||
nginx:latest \
|
||||
sh -c "ln -s /run/secrets/site.conf /etc/nginx/conf.d/site.conf && exec nginx -g 'daemon off;'"
|
||||
```
|
||||
|
@ -787,7 +787,7 @@ line.
|
|||
--name wordpress \
|
||||
--replicas 1 \
|
||||
--network mysql_private \
|
||||
--publish target=30000,port=80 \
|
||||
--publish published=30000,target=80 \
|
||||
--mount type=volume,source=wpdata,destination=/var/www/html \
|
||||
--secret source=mysql_password,target=wp_db_password,mode=0400 \
|
||||
-e WORDPRESS_DB_USER="wordpress" \
|
||||
|
|
|
@ -337,8 +337,8 @@ Keep reading for more information and use cases for each of these methods.
|
|||
#### Publish a service's ports using the routing mesh
|
||||
|
||||
To publish a service's ports externally to the swarm, use the
|
||||
`--publish <TARGET-PORT>:<SERVICE-PORT>` flag. The swarm makes the service
|
||||
accessible at the target port **on every swarm node**. If an external host
|
||||
`--publish <PUBLISHED-PORT>:<SERVICE-PORT>` flag. The swarm makes the service
|
||||
accessible at the published port **on every swarm node**. If an external host
|
||||
connects to that port on any swarm node, the routing mesh routes it to a task.
|
||||
The external host does not need to know the IP addresses or internally-used
|
||||
ports of the service tasks to interact with the service. When a user or process
|
||||
|
@ -354,7 +354,7 @@ three tasks on a 10-node swarm:
|
|||
```bash
|
||||
$ docker service create --name my_web \
|
||||
--replicas 3 \
|
||||
--publish target=8080,port=80 \
|
||||
--publish published=8080,target=80 \
|
||||
nginx
|
||||
```
|
||||
|
||||
|
|
|
@ -40,7 +40,7 @@ a throwaway registry, which you can discard afterward.
|
|||
1. Start the registry as a service on your swarm:
|
||||
|
||||
```bash
|
||||
$ docker service create --name registry --publish target=5000,port=5000 registry:2
|
||||
$ docker service create --name registry --publish published=5000,target=5000 registry:2
|
||||
```
|
||||
|
||||
2. Check its status with `docker service ls`:
|
||||
|
|
|
@ -325,7 +325,7 @@ $ docker service create \
|
|||
-e REGISTRY_HTTP_ADDR=0.0.0.0:80 \
|
||||
-e REGISTRY_HTTP_TLS_CERTIFICATE=/run/secrets/domain.crt \
|
||||
-e REGISTRY_HTTP_TLS_KEY=/run/secrets/domain.key \
|
||||
--publish target=80,port=80 \
|
||||
--publish published=80,target=80 \
|
||||
--replicas 1 \
|
||||
registry:2
|
||||
```
|
||||
|
|
Loading…
Reference in New Issue