Skip to content

Docker exports/diff/commits are racy #3675

@alexlarsson

Description

@alexlarsson

Currently when you do e.gl "docker diff" or "docker commit" the docker daemon reads the live filesystem that the container controls. This is risky since the content there is under the control of the container.

For instance, a container could create a directory /foo, and then after the daemon has started reading the directory switch it out for a symlink with an absolute filename and have the daemon start reading files outside the container. You can also cause the daemon to loop when traversing the filesystem in the same way.

Its also generally risky to have an operation like "docker commit" rely on non-atomic operations like a recursive tar, as its possible that the filesystem changes during the operation.

One solution is to be very careful in all file operations on a live container, using openat() & co rather that path concatenation when recursing in a filesystem. This doesn't solve the atomic commit issue, and unfortunately the go filepath.Walk() call doesn't use openat().

Another solution for btrfs and the lvm backend is to take a snapshot of the container image before doing the diff operation. This would make fs traversion safe and atomic. However, this doesn't work on aufs, (or other union fs:es like overlayfs).

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions