非常教程

Docker 17参考手册

引擎: 管理员指南 | Engine: Admin Guide

使用systemd控制和配置Docker(引擎) | Control and configure Docker with systemd (Engine)

许多 Linux 发行版使用 systemd 来启动 Docker 守护进程(daemon)。本文档展示了一些如何定制 Docker 设置的例子。

启动 Docker 守护进程(daemon)

手动启动

一旦安装了 Docker,您将需要启动 Docker 守护进程。大多数 Linux 发行版都用systemctl来启动服务。如果您没有systemctl,请使用service命令。

  • systemctl:$ sudo systemctl启动docker
  • service

$ sudo service docker start

在系统启动时自动启动

如果您希望 Docker 在启动时启动,请参阅配置 Docker 以在启动时启动。

自定义 Docker 守护进程(daemon)选项

有很多方法可以为你的 Docker 守护进程(daemon)配置守护进程标志和环境变量。推荐的方法是使用平台无关daemon.json文件,该文件默认位于Linux上/etc/docker/。请参阅守护程序(Daemon)配置文件。

您可以使用daemon.json配置几乎所有守护程序配置选项。以下示例配置了两个选项。您无法使用daemon.json机制配置的一件事是 HTTP 代理。

运行时间目录和存储驱动程序

您可能希望通过将 Docker 映像,容器和卷移动到单独的分区来控制用于 Docker 映像,容器和卷的磁盘空间。

要完成此操作,请在daemon.json文件中设置以下标志:

{
    "graph": "/mnt/docker-data",
    "storage-driver": "overlay"
}

http/HTTPS 代理

Docker 守护程序(daemon)使用HTTP_PROXYHTTPS_PROXY以及NO_PROXY环境变量在其启动环境来配置 HTTP 或 HTTPS 代理的行为。您无法配置

这些环境变量使用daemon.json文件。

此示例覆盖默认docker.service文件。

如果您位于 HTTP 或 HTTPS 代理服务器的后面,例如在公司设置中,则需要在 Docker systemd 服务文件中添加此配置。

1. 为 docker 服务创建一个 systemd 放置目录:

$ mkdir -p /etc/systemd/system/docker.service.d

2. 创建一个名为/etc/systemd/system/docker.service.d/http-proxy.conf的文件,添加HTTP_PROXY环境变量:

Service Environment="HTTP_PROXY=http://proxy.example.com:80/"

或者,如果您位于 HTTPS 代理服务器的后面,请创建一个名为/etc/systemd/system/docker.service.d/https-proxy.conf的文件以添加HTTPS_PROXY环境变量:

Service Environment="HTTPS_PROXY=https://proxy.example.com:443/"

1. 如果您有内部Docker注册表,您需要联系而无需代理,则可以通过NO_PROXY环境变量指定它们:

Environment =“HTTP_PROXY = http://proxy.example.com:80/”“NO_PROXY = localhost,127.0.0.1,docker -registry.somecorporation.com“

或者,如果您位于HTTPS代理服务器之后:

Environment =”HTTPS_PROXY = https://proxy.example.com:443/“”NO_PROXY = localhost,127.0.0.1,docker-registry.somecorporation .COM”

2. 冲洗更改:

$ sudo systemctl 守护进程重新加载

3. 重新启动Docker:$ sudo systemctl restart docker

4. 验证已加载配置:

$ systemctl show --property =环境docker Environment = HTTP_PROXY = http://proxy.example.com:80/

或者,如果您位于HTTPS代理服务器的后面:

$ systemctl show --property =Environment docker = HTTPS_PROXY = https://proxy.example.com:443/

手动创建 systemd 单元文件

在没有包的情况下安装二进制文件时,您可能需要将 Docker 与 systemd 集成。为此,将两个单元文件(servicesocket)从 github 存储库安装到/etc/systemd/system

docker, daemon, systemd, configuration

引擎: 管理员指南 | Engine: Admin Guide相关

1.Amazon CloudWatch记录日志记录驱动程序(引擎) | Amazon CloudWatch logs logging driver (Engine)
2. 绑定挂载 | Bind mounts (Engine)
3.使用Prometheus(引擎)收集Docker指标 | Collect Docker metrics with Prometheus (Engine)
4.配置和运行Docker(引擎) | Configuring and running Docker (Engine)
5.配置日志记录驱动程序 | Configuring logging drivers (Engine)
6.ETW日志记录驱动程序(引擎) | ETW logging driver (Engine)
7.流利的日志驱动程序(引擎) | Fluentd logging driver (Engine)
8.格式化命令和日志输出(引擎) | Format command and log output (Engine)
9.Google Cloud日志记录驱动程序(引擎) | Google Cloud logging driver (Engine)
10.Graylog扩展格式(GELF)日志记录驱动程序(引擎) | Graylog Extended Format (GELF) logging driver (Engine)
11.Journald日志记录驱动程序(引擎) | Journald logging driver (Engine)
12.JSON文件日志记录驱动程序(引擎) | JSON File logging driver (Engine)
13.在守护进程停机期间保持容器处于活动状态(引擎) | Keep containers alive during daemon downtime (Engine)
14.限制容器的资源(引擎) | Limit a container's resources (Engine)
15.通过大使容器链接(引擎) | Link via an ambassador container (Engine)
16.记录驱动程序的日志标记(引擎) | Log tags for logging driver (Engine)
17.Logentries日志驱动程序(引擎) | Logentries logging driver (Engine)
18.PowerShell DSC用法(引擎) | PowerShell DSC usage (Engine)
19.修剪未使用的Docker对象(引擎) | Prune unused Docker objects (Engine)
20.在容器中运行多个服务(引擎) | Run multiple services in a container (Engine)
21.运行时指标(引擎) | Runtime metrics (Engine)
22.Splunk日志记录驱动程序(引擎) | Splunk logging driver (Engine)
23.自动启动容器(引擎) | Start containers automatically (Engine)
24.存储概述(引擎) | Storage overview (Engine)
25.Syslog日志记录驱动程序(引擎) | Syslog logging driver (Engine)
26.tmpfs mounts
27.解决卷问题(引擎) | Troubleshoot volume problems (Engine)
28.使用日志驱动程序插件(引擎) | Use a logging driver plugin (Engine)
29.使用Ansible(引擎) | Using Ansible (Engine)
30.使用Chef(引擎) | Using Chef (Engine)
31.使用Puppet(引擎) | Using Puppet (Engine)
32.查看容器的日志(引擎) | View a container's logs (Engine)
33.Volumes (Engine)
Docker 17

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

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