非常教程

Docker 17参考手册

引擎 | Engine

锁定你的群(引擎) | Lock your swarm (Engine)

在 Docker 1.13 及更高版本中,群集管理器使用的 Raft 日志默认在磁盘上加密。这种静态加密可以保护您的服务配置和数据免受攻击者的攻击,而攻击者可以访问加密的 Raft 日志。此功能推出的原因之一是支持新的 Docker 机密功能。

当 Docke r重新启动时,用于加密群集节点间通信的 TLS 密钥以及用于加密和解密磁盘上的 Raft 日志的密钥都会加载到每个管理器节点的内存中。Docker 1.13引入了保护相互TLS加密密钥和用于加密和解密 Raft 日志的密钥的功能,允许您拥有这些密钥的所有权并要求手动解锁管理人员。该功能称为自动锁定

当 Docker 重新启动时,您必须先使用 Docker 在群集锁定时生成的密钥加密密钥解锁群集。您可以随时旋转此密钥加密密钥。

注意:当新节点加入群体时,不需要解锁群体,因为密钥通过相互 TLS 传播给它。

使用自动锁定初始化群集

当您初始化新的群集时,可以使用该--autolock标志在Docker 重新启动时启用群集管理器节点的自动锁定。

$ docker swarm init --autolock

Swarm initialized: current node (k1q27tfyx9rncpixhk69sa61v) is now a manager.

To add a worker to this swarm, run the following command:

    docker swarm join \
    --token SWMTKN-1-0j52ln6hxjpxk2wgk917abcnxywj3xed0y8vi1e5m9t3uttrtu-7bnxvvlz2mrcpfonjuztmtts9 \
    172.31.46.109:2377

To add a manager to this swarm, run 'docker swarm join-token manager' and follow the instructions.

To unlock a swarm manager after it restarts, run the `docker swarm unlock`
command and provide the following key:

    SWMKEY-1-WuYH/IX284+lRcXuoVf38viIDK3HJEKY13MIHX+tTt8

将密钥存放在安全的地方,例如密码管理器。

当 Docker 重新启动时,您需要解锁群集。您会看到类似以下的错误,并且服务无法启动。

$ sudo service docker restart

$ docker service ls

Error response from daemon: Swarm is encrypted and needs to be unlocked before it can be used. Please use "docker swarm unlock" to unlock it.

在现有群集上启用或禁用自动锁定

要在现有群集上启用自动锁定,请将该autolock标志设置为true

$ docker swarm update --autolock=true

Swarm updated.
To unlock a swarm manager after it restarts, run the `docker swarm unlock`
command and provide the following key:

    SWMKEY-1-+MrE8NgAyKj5r3NcR4FiQMdgu+7W72urH0EZeSmP/0Y

Please remember to store this key in a password manager, since without it you
will not be able to restart the manager.

要禁用自动锁定,请设置--autolockfalse。用于读写 Raft 日志的相互 TLS 密钥和加密密钥将以未加密方式存储在磁盘上。在未加密的情况下存储加密密钥的风险与无需解锁每个管理器就能够重新启动群集的便利性之间存在折衷。

$ docker swarm update --autolock=false

在禁用自动锁定功能后,如果管理器在配置为使用旧密钥进行锁定时发生故障,请将解锁密钥保留一小段时间。

解锁群

要解锁已锁定的群组,请使用docker swarm unlock

$ docker swarm unlock

Please enter unlock key:

输入在锁定群组或旋转钥匙时生成并显示在命令输出中的加密密钥,并且群体解锁。

查看正在运行的群体的当前解锁密钥

考虑一下你的团队按预期运行的情况,然后经理节点变得不可用。您排除故障并使物理节点重新联机,但您需要通过提供解锁密钥来解锁管理器,以便读取加密凭证和 Raft 日志。

如果自从节点离开群集后密钥没有旋转,并且群体中有法定的功能管理器节点,则可以使用docker swarm unlock-key没有任何参数的方式查看当前的解锁密钥。

$ docker swarm unlock-key

To unlock a swarm manager after it restarts, run the `docker swarm unlock`
command and provide the following key:

    SWMKEY-1-8jDgbUNlJtUe5P/lcr9IXGVxqZpZUXPzd+qzcGp4ZYA

Please remember to store this key in a password manager, since without it you
will not be able to restart the manager.

如果在群组节点变得不可用并且没有前一个密钥的记录后旋转密钥,则可能需要强制经理离开群集并将其作为新经理加入群组。

旋转解锁键

您应定期轮换已锁定的群组的解锁密钥。

$ docker swarm unlock-key --rotate

Successfully rotated manager unlock key.

To unlock a swarm manager after it restarts, run the `docker swarm unlock`
command and provide the following key:

    SWMKEY-1-8jDgbUNlJtUe5P/lcr9IXGVxqZpZUXPzd+qzcGp4ZYA

Please remember to store this key in a password manager, since without it you
will not be able to restart the manager.

警告:旋转解锁密钥时,请将旧密钥的记录保留几分钟,以便经理在获取新密钥之前关闭,但仍旧可能会锁定旧密钥。

群,经理,锁,解锁,自动锁定,加密

引擎 | 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.管理群中的节点(引擎) | Manage nodes in a swarm (Engine)
47.使用Docker机密管理敏感数据(引擎) | Manage sensitive data with Docker secrets (Engine)
48.使用PKI管理swarm安全性(引擎) | Manage swarm security with PKI (Engine)
49.管理群体服务网络(引擎) | Manage swarm service networks (Engine)
50.迁移到引擎1.10 | Migrate to Engine 1.10
51.可选的Linux安装后步骤(引擎) | Optional Linux post-installation steps (Engine)
52.总览 | Overview (Engine)
53.总览 | Overview (Engine)
54.PostgreSQL(引擎) | PostgreSQL (Engine)
55.群集模式中的筏共识(引擎) | Raft consensus in swarm mode (Engine)
56.Riak (Engine)
57.以群集模式运行Docker Engine | Run Docker Engine in swarm mode
58.扩展服务(引擎) | Scale the service (Engine)
59.SDKs (Engine)
60.选择一个存储驱动 | Select a storage driver (Engine)
61.设置教程(引擎) | Set up for the tutorial (Engine)
62.SSHd (Engine)
63.存储驱动总览 | Storage driver overview (Engine)
64.存储服务配置数据(引擎) | Store service configuration data (Engine)
65.Swarm管理指南(引擎) | Swarm administration guide (Engine)
66.Swarm模式关键概念(引擎) | Swarm mode key concepts (Engine)
67.Swarm模式覆盖网络安全模型(引擎) | Swarm mode overlay network security model (Engine)
68.群模式概述(引擎) | Swarm mode overview (Engine)
69.Ubuntu (Engine)
70.Ubuntu (Engine)
71.了解容器通信(引擎) | Understand container communication (Engine)
72.使用多阶段构建(引擎) | Use multi-stage builds (Engine)
73.使用swarm模式路由网格(引擎) | Use swarm mode routing mesh (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