dock docs ner light map containe file balanced
需要的 ingress 网络映射,还是 host 宿主机端口映射:
https://docs.docker.com/compose/compose-file/#secrets
========================
nginx
--publish mode=host,published=80,target=80 \
docker service create --name web \
==========================
Expose ports.
Either specify both ports (
), or just the container port (a random host port will be chosen).
- HOST:CONTAINER
Note: When mapping ports in the
format, you may experience erroneous results when using a container port lower than 60, because YAML will parse numbers in the format
- HOST:CONTAINER
as sexagesimal (base 60). For this reason, we recommend always explicitly specifying your port mappings as strings.
- xx:yy
- ports:
- - "3000"
- - "3000-3005"
- - "8000:8000"
- - "9090-9091:8080-8081"
- - "49100:22"
- - "127.0.0.1:8001:8001"
- - "127.0.0.1:5000-5010:5000-5010"
- - "6060:6060/udp"
The long form syntax allows the configuration of additional fields that can't be expressed in the short form.
: the port inside the container
- target
: the publicly exposed port
- published
: the port protocol (
- protocol
or
- tcp
)
- udp
:
- mode
for publishing a host port on each node, or
- host
for a swarm mode port which will be load balanced.
- ingress
- ports:
- - target: 80
- published: 8080
- protocol: tcp mode: host
Note: The long syntax is new in v3.2
官方文档,才是正途 - docker-compose
来源: http://www.bubuko.com/infodetail-2088528.html