BRIDGE networking: 应用于Docker Application.docker
USER networking: 应用于Docker Application.适合于使用自定义docker网络的状况。数组
HOST networking: 应用与Docker Application和非Docker Application。网络
containerPort: 用于容器部署时,在bridge或者user模式网络下 ,指定容器里面的具体端口。架构
hostPort:指服务绑定到主机上的端口,使用bridge或者user网络模式时,经过撇脂port mapping来映射主机端口到容器端口,在host网络模式是,默认要求的端口就是主机端口。注意,只有主机端口能够经过环境变量被获取到。app
servicePort:在marathon里面建立一个新应用时,你可能会分配一个或多个服务给该应用, 能够指定全部的合法端口或者指定为0让marathon来自动分配服务端口。若是你本身指定服务端口,必须确保该端口在全部应用中惟一。tcp
portMapping: 在Docker Bridge模式,portMapping对于须要从外部访问容器内服务来讲是必须的,每一个端口须要有一条记录,一条记录包含4个元素:host port, container port, service port and protocol。ui
{ "container": { "portMappings": [ <port-mapping>... ], ... }, ... }
container
and container/bridge
mode networking.requirePorts
does not apply to portMappings
ports: 在host网络模式下使用,ports数组用来定义端口,而且须要做为resurce offer来考虑。只有在portMapping没有指定时才须要。ports或者portDefinitions只须要定义一个。this
portDefinitions: 只在host网络模式下,没有指定portMapping时使用。用来代替ports数组的,能够指定 port name, protocol and labels。spa
{ "portDefinitions": [ <port-definition>... ], "requirePorts": <bool>, ... }
host
mode networking.requirePorts
applies to portDefinitions
.protocol: tcp或者/和udp,当Docker容器使用BRIDGE
or USER网络模式时,做为portMapping的一部分使用。
code
requirePorts: 设为true的时候要求在验证在收到的resource offer里面有相应的配置的端口,在BRIDGE
or USER网络模式时不使用该配置。
VIPS: 若是使用DC/OS集群,能够使用VIPs来简化端口管理,VIPs简化了集群内部应用之间的通讯,实现了面向服务的架构,VIPs将一个单一地址的流量映射到多个地址和端口上。
vip包含3个组成部分:Private virtual IP address, Port (a port which the service is available on), Service name.
vip按以下格式转换的:
<service-name>.marathon.l4lb.thisdcos.directory:<port>
{ "id": "/my-service", "cmd": "sleep 10", "cpus": 1, "portDefinitions": [ { "protocol": "tcp", "port": 5555, "labels": { "VIP_0": "/my-service:5555" }, "name": "my-vip" } ] }
在上面这段设置中,DCOS集群内部APP能够经过my-service.marathon.l4lb.thisdcos.directory:5555来访问服务。
To view the VIP for Kafka, run
dcos kafka endpoints broker
from the DC/OS CLI.