Home Explore Blog Models CI



docker

1st chunk of `content/manuals/engine/storage/drivers/vfs-driver.md`
f202a0e1ce6e38afe62e51946bc3241059842c8c8682a92a000000010000096b
---
description: Learn how to optimize your use of VFS driver.
keywords: container, storage, driver, vfs
title: VFS storage driver
aliases:
  - /storage/storagedriver/vfs-driver/
---

The VFS storage driver isn't a union filesystem. Each layer is a
directory on disk, and there is no copy-on-write support. To create a new
layer, a "deep copy" is done of the previous layer. This leads to lower
performance and more space used on disk than other storage drivers. However, it
is robust, stable, and works in every environment. It can also be used as a
mechanism to verify other storage back-ends against, in a testing environment.

## Configure Docker with the `vfs` storage driver

1. Stop Docker.

   ```console
   $ sudo systemctl stop docker
   ```

2.  Edit `/etc/docker/daemon.json`. If it doesn't yet exist, create it. Assuming
    that the file was empty, add the following contents.

    ```json
    {
      "storage-driver": "vfs"
    }
    ```

    If you want to set a quota to control the maximum size the VFS storage
    driver can use, set the `size` option on the `storage-opts` key.

    ```json
    {
      "storage-driver": "vfs",
      "storage-opts": ["size=256M"]
    }
    ```

    Docker doesn't start if the `daemon.json` file contains invalid JSON.

3.  Start Docker.

    ```console
    $ sudo systemctl start docker
    ```

4.  Verify that the daemon is using the `vfs` storage driver.
    Use the `docker info` command and look for `Storage Driver`.

    ```console
    $ docker info

    Storage Driver: vfs
    ...
    ```

Docker is now using the `vfs` storage driver. Docker has automatically
created the `/var/lib/docker/vfs/` directory, which contains all the layers
used by running containers.

## How the `vfs` storage driver works

Each image layer and the writable container layer are represented on the Docker
host as subdirectories within `/var/lib/docker/`. The union mount provides the
unified view of all layers. The directory names don't directly correspond to
the IDs of the layers themselves.

VFS doesn't support copy-on-write (COW). Each time a new layer is created,
it's a deep copy of its parent layer. These layers are all located under
`/var/lib/docker/vfs/dir/`.

### Example: Image and container on-disk constructs

The following `docker pull` command shows a Docker host downloading a Docker
image comprising five layers.

```console
$ docker pull ubuntu

Title: VFS Storage Driver Configuration and Functionality
Summary
The VFS storage driver in Docker operates by creating a directory on disk for each layer, performing a deep copy for new layers instead of using copy-on-write. This driver is stable and universally compatible but less performant and space-efficient than others. The document outlines how to configure Docker to use the VFS driver, including setting a storage quota, and explains how it represents image layers and containers as subdirectories within `/var/lib/docker/vfs/`.