非常教程

Docker 17参考手册

引擎 | Engine

使用VFS存储驱动程序(引擎) | Use the VFS storage driver (Engine)

VFS存储驱动程序不是联合文件系统;相反,每个图层都是磁盘上的目录,并且没有写时复制支持。要创建一个新图层,先前的图层会进行“深层复制”。与其他存储驱动程序相比,这会导致磁盘性能下降和磁盘使用空间更多。但是,它强大,稳定,适用于各种环境。它也可以用作在测试环境中验证其他存储后端的机制。

使用vfs存储驱动程序配置Docker

  1. 停止Docker。$ sudo systemctl stop docker

2. 编辑/etc/docker/daemon.json。如果它还不存在,请创建它。假设文件为空,请添加以下内容。

{ "storage-driver": "vfs" }

如果daemon.json文件包含格式错误的JSON,Docker将无法启动。

3. 启动Docker。$ sudo systemctl start docker

4. 验证守护进程正在使用vfs存储驱动程序。使用该docker info命令并查找Storage DriverBacking filesystem

$ docker info存储驱动程序:vfs <output truncated>

Docker现在使用vfs存储驱动程序。Docker自动创建了/var/lib/docker/vfs/目录,其中包含运行容器使用的所有图层。

如何vfs存储驱动程序作品

VFS不是联合文件系统。相反,每个图像层和可写容器层都在Docker主机上表示为子目录/var/lib/docker/。联合安装提供了所有图层的统一视图。目录名称不直接对应于图层本身的ID。

VFS不支持写入时拷贝(COW),因此每次创建一个新图层时,它都是其父图层的深层副本。这些图层都位于下方/var/lib/docker/dir/

示例:映像和容器在磁盘上的结构

以下docker pull命令显示了一个Docker主机下载一个包含五层的Docker镜像。

$ docker pull ubuntu

Using default tag: latest
latest: Pulling from library/ubuntu
e0a742c2abfd: Pull complete
486cb8339a27: Pull complete
dc6f0d824617: Pull complete
4f7a5649a30e: Pull complete
672363445ad2: Pull complete
Digest: sha256:84c334414e2bfdcae99509a6add166bbb4fa4041dc3fa6af08046a66fed3005f
Status: Downloaded newer image for ubuntu:latest

pull之后,这些层中的每一层都被表示为一个子目录/var/lib/docker/vfs/dir/。目录名称与docker pull命令中显示的图像层ID不相关。要查看每个图层在磁盘上占用的大小,可以使用du -sh命令,该命令将大小视为可读的值。

$ ls -l /var/lib/docker/vfs/dir/

total 0
drwxr-xr-x.  2 root root  19 Aug  2 18:19 3262dfbe53dac3e1ab7dcc8ad5d8c4d586a11d2ac3c4234892e34bff7f6b821e
drwxr-xr-x. 21 root root 224 Aug  2 18:23 6af21814449345f55d88c403e66564faad965d6afa84b294ae6e740c9ded2561
drwxr-xr-x. 21 root root 224 Aug  2 18:23 6d3be4585ba32f9f5cbff0110e8d07aea5f5b9fbb1439677c27e7dfee263171c
drwxr-xr-x. 21 root root 224 Aug  2 18:23 9ecd2d88ca177413ab89f987e1507325285a7418fc76d0dcb4bc021447ba2bab
drwxr-xr-x. 21 root root 224 Aug  2 18:23 a292ac6341a65bf3a5da7b7c251e19de1294bd2ec32828de621d41c7ad31f895
drwxr-xr-x. 21 root root 224 Aug  2 18:23 e92be7a4a4e3ccbb7dd87695bca1a0ea373d4f673f455491b1342b33ed91446b
$ du -sh /var/lib/docker/vfs/dir/*

4.0K	/var/lib/docker/vfs/dir/3262dfbe53dac3e1ab7dcc8ad5d8c4d586a11d2ac3c4234892e34bff7f6b821e
125M	/var/lib/docker/vfs/dir/6af21814449345f55d88c403e66564faad965d6afa84b294ae6e740c9ded2561
104M	/var/lib/docker/vfs/dir/6d3be4585ba32f9f5cbff0110e8d07aea5f5b9fbb1439677c27e7dfee263171c
125M	/var/lib/docker/vfs/dir/9ecd2d88ca177413ab89f987e1507325285a7418fc76d0dcb4bc021447ba2bab
104M	/var/lib/docker/vfs/dir/a292ac6341a65bf3a5da7b7c251e19de1294bd2ec32828de621d41c7ad31f895
104M	/var/lib/docker/vfs/dir/e92be7a4a4e3ccbb7dd87695bca1a0ea373d4f673f455491b1342b33ed91446b

以上输出结果显示三层各取104M,两层取125M。这些目录彼此之间只有很小的差异,但在磁盘上占用的空间几乎相同。这是使用vfs存储驱动程序的一个缺点。

相关信息

  • 了解图像,容器和存储驱动程序
  • 选择存储驱动程序
  • AUFS存储驱动程序在实践中
  • OverlayFS存储驱动程序在实践中的应用
  • Btrfs存储驱动程序在实践中的应用
  • 设备Mapper存储驱动程序在实践中的应用

容器,存储,驱动程序,vfs

引擎 | 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.使用swarm模式路由网格(引擎) | Use swarm mode routing mesh (Engine)
75.使用AUFS存储驱动程序(引擎) | Use the AUFS storage driver (Engine)
76.使用Btrfs存储驱动程序(引擎) | Use the Btrfs storage driver (Engine)
77.使用设备映射器存储驱动程序(引擎) | Use the Device mapper storage driver (Engine)
78.使用OverlayFS存储驱动程序(引擎) | Use the OverlayFS 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