非常教程

Docker 17参考手册

引擎 | Engine

使用swarm模式路由网格(引擎) | Use swarm mode routing mesh (Engine)

Docker Engine群集模式可以轻松发布服务端口,使其可以用于群集外部的资源。所有节点都参与入口路由网格。路由网格使群体中的每个节点都可以接受群集中运行的任何服务的已发布端口上的连接,即使节点上没有运行任何任务。路由网格将所有传入请求路由到可用节点上的已发布端口以激活容器。

为了使用群集中的入口网络,在启用群集模式之前,需要在群集节点之间打开以下端口:

  • 端口7946TCP/UDP用于容器网络发现。
  • 端口4789UDP用于容器入口网络。

您还必须打开群集节点与需要访问端口的任何外部资源(如外部负载平衡器)之间的发布端口。

发布服务的端口

--publish创建服务时使用该标志发布端口:

$ docker service create \
  --name <SERVICE-NAME> \
  --publish <PUBLISHED-PORT>:<TARGET-PORT> \
  <IMAGE>

=<TARGET-PORT>是容器侦听的端口。这<PUBLISHED-PORT>是群体提供服务的端口。

例如,以下命令将nginx容器中的端口80发布到群集中的任何节点的端口8080:

$ docker service create \
  --name my-web \
  --publish 8080:80 \
  --replicas 2 \
  nginx

当您在任何节点上访问端口8080时,群集负载均衡器会将您的请求路由到活动容器。

路由网格在发布的端口上侦听分配给该节点的任何IP地址。对于外部可路由的IP地址,该端口可在主机外部使用。对于所有其他IP地址,访问只能在主机内使用。

使用swarm模式路由网格(引擎)  |  Use swarm mode routing mesh (Engine)

您可以使用以下命令发布现有服务的端口:

$ docker service update \
  --publish-add <PUBLISHED-PORT>:<TARGET-PORT> \
  <SERVICE>

您可以使用docker service inspect查看服务的发布端口。例如:

$ docker service inspect --format="{{json .Endpoint.Spec.Ports}}" my-web

[{"Protocol":"tcp","TargetPort":80,"PublishedPort":8080}]

输出显示<TARGET-PORT>来自容器的<PUBLISHED-PORT>节点以及节点侦听服务请求的位置。

仅为TCP发布端口或仅发布UDP

默认情况下,当发布端口时,它是TCP端口。您可以专门发布UDP端口,而不是TCP端口,也可以是TCP端口之外的端口。当您同时发布TCP和UDP端口时,Docker 1.12.2和更早版本要求您添加后缀/tcp对于TCP端口。否则它是可选的。

仅限TCP

以下两个命令是等效的。

$ docker service create --name dns-cache -p 53:53 dns-cache

$ docker service create --name dns-cache -p 53:53/tcp dns-cache

TCP和UDP

$ docker service create --name dns-cache -p 53:53/tcp -p 53:53/udp dns-cache

仅限UDP

$ docker service create --name dns-cache -p 53:53/udp dns-cache

配置外部负载平衡器

您可以配置外部负载平衡器以将请求路由到群集服务。例如,您可以配置HAProxy以平衡对发布到端口8080的nginx服务的请求。

使用swarm模式路由网格(引擎)  |  Use swarm mode routing mesh (Engine)

在这种情况下,端口8080必须在负载均衡器和群集中的节点之间打开。群集节点可以驻留在代理服务器可以访问的专用网络上,但不能公开访问。

您可以配置负载均衡器来平衡群集中每个节点之间的请求,即使节点上没有任何计划任务。例如,您可以在以下位置使用HAProxy配置/etc/haproxy/haproxy.cfg

global
        log /dev/log    local0
        log /dev/log    local1 notice
...snip...

# Configure HAProxy to listen on port 80
frontend http_front
   bind *:80
   stats uri /haproxy?stats
   default_backend http_back

# Configure HAProxy to route requests to swarm nodes on port 8080
backend http_back
   balance roundrobin
   server node1 192.168.99.100:8080 check
   server node2 192.168.99.101:8080 check
   server node3 192.168.99.102:8080 check

当您访问端口80上的HAProxy负载平衡器时,它会将请求转发到群集中的节点。群集路由网格将请求路由到活动任务。如果由于任何原因,群集调度程序将任务分派给不同的节点,则不需要重新配置负载均衡器。

您可以配置任何类型的负载均衡器以将请求路由到群集节点。要了解有关HAProxy的更多信息,请参阅HAProxy文档。

了解更多

  • 将服务部署到群集

指导,群体模式,群体,网络,入口,路由网格

引擎 | Engine相关

1..NET核心应用程序(引擎) | .NET Core application (Engine)
2.关于图像,容器和存储驱动程序(引擎) | About images, containers, and storage drivers (Engine)
3.向swarm添加节点(Engine) | Add nodes to the swarm (Engine)
4.应用自定义元数据(引擎) | Apply custom metadata (Engine)
5.应用滚动更新(引擎) | Apply rolling updates (Engine)
6.apt-cacher-ng
7.编写Dockerfiles(引擎)的最佳实践 | Best practices for writing Dockerfiles (Engine)
8.二进制(引擎) | Binaries (Engine)
9.将容器端口绑定到主机(引擎) | Bind container ports to the host (Engine)
10.突破性变化(引擎) | Breaking changes (Engine)
11.建立自己的网桥 | Build your own bridge (Engine)
12.CentOS (Engine)
13.CentOS (Engine)
14.配置容器DNS(引擎) | Configure container DNS (Engine)
15.在用户定义的网络中配置容器DNS(引擎) | Configure container DNS in user-defined networks (Engine)
16.CouchDB (Engine)
17.创建基本映像(引擎) | Create a base image (Engine)
18.创建群(引擎) | Create a swarm (Engine)
19.自定义docker0网桥(引擎) | Customize the docker0 bridge (Engine)
20.Debian (Engine)
21.默认桥接网络 | Default bridge network
22.删除服务(引擎) | Delete the service (Engine)
23.部署服务(引擎) | Deploy a service (Engine)
24.将服务部署到一个群(引擎) | Deploy services to a swarm (Engine)
25.不推荐的引擎功能 | Deprecated Engine features
26.Docker容器网络(引擎) | Docker container networking (Engine)
27.Docker概述(引擎) | Docker overview (Engine)
28.Docker运行参考(引擎) | Docker run reference (Engine)
29.Dockerfile引用(引擎) | Dockerfile reference (Engine)
30.Dockerize应用程序 | Dockerize an application
31.排空节点(引擎) | Drain a node (Engine)
32.引擎 | Engine
33.FAQ(引擎) | FAQ (Engine)
34.Fedora (Engine)
35.开始 | Get started (Engine)
36.开始使用macvlan网络驱动程序 | Get started with macvlan network driver (Engine)
37.开始使用多主机网络 | Get started with multi-host networking (Engine)
38.节点如何工作 | How nodes work (Engine)
39.服务如何运作(引擎) | How services work (Engine)
40.图像管理 | Image management (Engine)
41.检查服务(引擎) | Inspect the service (Engine)
42.安装Docker(引擎) | Install Docker (Engine)
43.IPv6与Docker(引擎) | IPv6 with Docker (Engine)
44.将节点加入群集(引擎) | Join nodes to a swarm (Engine)
45.旧容器链接(引擎) | Legacy container links (Engine)
46.锁定你的群(引擎) | Lock your swarm (Engine)
47.管理群中的节点(引擎) | Manage nodes in a swarm (Engine)
48.使用Docker机密管理敏感数据(引擎) | Manage sensitive data with Docker secrets (Engine)
49.使用PKI管理swarm安全性(引擎) | Manage swarm security with PKI (Engine)
50.管理群体服务网络(引擎) | Manage swarm service networks (Engine)
51.迁移到引擎1.10 | Migrate to Engine 1.10
52.可选的Linux安装后步骤(引擎) | Optional Linux post-installation steps (Engine)
53.总览 | Overview (Engine)
54.总览 | Overview (Engine)
55.PostgreSQL(引擎) | PostgreSQL (Engine)
56.群集模式中的筏共识(引擎) | Raft consensus in swarm mode (Engine)
57.Riak (Engine)
58.以群集模式运行Docker Engine | Run Docker Engine in swarm mode
59.扩展服务(引擎) | Scale the service (Engine)
60.SDKs (Engine)
61.选择一个存储驱动 | Select a storage driver (Engine)
62.设置教程(引擎) | Set up for the tutorial (Engine)
63.SSHd (Engine)
64.存储驱动总览 | Storage driver overview (Engine)
65.存储服务配置数据(引擎) | Store service configuration data (Engine)
66.Swarm管理指南(引擎) | Swarm administration guide (Engine)
67.Swarm模式关键概念(引擎) | Swarm mode key concepts (Engine)
68.Swarm模式覆盖网络安全模型(引擎) | Swarm mode overlay network security model (Engine)
69.群模式概述(引擎) | Swarm mode overview (Engine)
70.Ubuntu (Engine)
71.Ubuntu (Engine)
72.了解容器通信(引擎) | Understand container communication (Engine)
73.使用多阶段构建(引擎) | Use multi-stage builds (Engine)
74.使用AUFS存储驱动程序(引擎) | Use the AUFS storage driver (Engine)
75.使用Btrfs存储驱动程序(引擎) | Use the Btrfs storage driver (Engine)
76.使用设备映射器存储驱动程序(引擎) | Use the Device mapper storage driver (Engine)
77.使用OverlayFS存储驱动程序(引擎) | Use the OverlayFS storage driver (Engine)
78.使用VFS存储驱动程序(引擎) | Use the VFS storage driver (Engine)
79.使用ZFS存储驱动程序(引擎) | Use the ZFS storage driver (Engine)
80.处理图像 | Work with images
81.使用网络命令(引擎) | Work with network commands (Engine)
Docker 17

Docker 是一个开源的应用容器引擎,让开发者可以打包他们的应用以及依赖包到一个可移植的容器中,然后发布到任何流行的 Linux 机器上,也可以实现虚拟化。容器是完全使用沙箱机制,相互之间不会有任何接口。

主页 https://docker.com/
源码 https://github.com/docker/docker
版本 17
发布版本 17.06