项目作者: AkihiroSuda

项目描述 :
fuse-overlayfs plugin for rootless containerd
高级语言: Go
项目地址: git://github.com/AkihiroSuda/containerd-fuse-overlayfs.git
创建时间: 2019-10-20T06:26:26Z
项目社区:https://github.com/AkihiroSuda/containerd-fuse-overlayfs

开源协议:Apache License 2.0

下载


fuse-overlayfs snapshotter plugin for containerd

Unlike overlayfs, fuse-overlayfs can be used as a non-root user on almost all recent distros.

You do NOT need this fuse-overlayfs plugin on the following environments, because they support the real overlayfs for non-root users:

fuse-overlayfs-snapshotter is a non-core sub-project of containerd.

Requirements

  • kernel >= 4.18
  • containerd >= 1.4
  • fuse-overlayfs >= 0.7.0

Setup

Two installation options are supported:

  1. Embed fuse-overlayfs plugin into the containerd binary
  2. Execute fuse-overlayfs plugin as a separate binary

Choose 1 if you don’t mind recompiling containerd, otherwise choose 2.

Option 1: Embed fuse-overlayfs plugin into the containerd binary

Create builtins_fuseoverlayfs_linux.go under $GOPATH/src/github.com/containerd/containerd/cmd/containerd/builtins
with the following content, and recompile the containerd binary:

  1. /*
  2. Copyright The containerd Authors.
  3. Licensed under the Apache License, Version 2.0 (the "License");
  4. you may not use this file except in compliance with the License.
  5. You may obtain a copy of the License at
  6. http://www.apache.org/licenses/LICENSE-2.0
  7. Unless required by applicable law or agreed to in writing, software
  8. distributed under the License is distributed on an "AS IS" BASIS,
  9. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. See the License for the specific language governing permissions and
  11. limitations under the License.
  12. */
  13. package main
  14. import _ "github.com/containerd/fuse-overlayfs-snapshotter/v2/plugin"

No extra configuration is needed.

See https://github.com/containerd/containerd/blob/master/docs/rootless.md for how to run containerd as a non-root user.

Option 2: Execute fuse-overlayfs plugin as a separate binary

“Easy way”

The easiest way is to use containerd-rootless-setuptool.sh included in nerdctl.

  1. $ containerd-rootless-setuptool.sh install
  2. $ containerd-rootless-setuptool.sh install-fuse-overlayfs
  3. [INFO] Creating "/home/exampleuser/.config/systemd/user/containerd-fuse-overlayfs.service"
  4. ...
  5. [INFO] Installed "containerd-fuse-overlayfs.service" successfully.
  6. [INFO] To control "containerd-fuse-overlayfs.service", run: `systemctl --user (start|stop|restart) containerd-fuse-overlayfs.service`
  7. [INFO] Add the following lines to "/home/exampleuser/.config/containerd/config.toml" manually:
  8. ### BEGIN ###
  9. [proxy_plugins]
  10. [proxy_plugins."fuse-overlayfs"]
  11. type = "snapshot"
  12. address = "/run/user/1000/containerd-fuse-overlayfs.sock"
  13. ### END ###
  14. [INFO] Set `export CONTAINERD_SNAPSHOTTER="fuse-overlayfs"` to use the fuse-overlayfs snapshotter.

Add the [proxy_plugins."fuse-overlayfs"] configuration shown above to ~/.config/containerd/config.toml.
“1000” needs to be replaced with your actual UID.

“Hard way”


Click here to show the “hard way”



Install containerd-fuse-overlayfs-grpc binary. The binary will be installed under $DESTDIR/bin.
console $ make && DESTDIR=$HOME make install
Create the following configuration in ~/.config/containerd/config.toml:
toml version = 2 # substitute "/home/suda" with your own $HOME root = "/home/suda/.local/share/containerd" # substitute "/run/user/1001" with your own $XDG_RUNTIME_DIR state = "/run/user/1001/containerd" [grpc] address = "/run/user/1001/containerd/containerd.sock" [proxy_plugins] [proxy_plugins."fuse-overlayfs"] type = "snapshot" address = "/run/user/1001/containerd/fuse-overlayfs.sock"

Start RootlessKit with sleep infinity (or any kind of “pause” command):
console $ rootlesskit \ --net=slirp4netns --disable-host-loopback \ --copy-up=/etc --copy-up=/run \ --state-dir=$XDG_RUNTIME_DIR/rootlesskit-containerd \ sh -c "rm -rf /run/containerd ; sleep infinity"
(Note: rm -rf /run/containerd is a workaround for containerd/containerd#2767)
Enter the RootlessKit namespaces and run containerd-fuse-overlayfs-grpc:
console $ nsenter -U --preserve-credentials -m -n -t $(cat $XDG_RUNTIME_DIR/rootlesskit-containerd/child_pid) \ containerd-fuse-overlayfs-grpc $XDG_RUNTIME_DIR/containerd/fuse-overlayfs.sock $HOME/.local/share/containerd-fuse-overlayfs

* Enter the same namespaces and run containerd:
console $ nsenter -U --preserve-credentials -m -n -t $(cat $XDG_RUNTIME_DIR/rootlesskit-containerd/child_pid) \ containerd -c $HOME/.config/containerd/config.toml


Usage

  1. $ export CONTAINERD_SNAPSHOTTER=fuse-overlayfs
  2. $ nerdctl run ...

How to test

To run the test as a non-root user, RootlessKit needs to be installed.

  1. $ go test -exec rootlesskit -test.v -test.root

Project details

fuse-overlayfs-snapshotter is a containerd non-core sub-project, licensed under the Apache 2.0 license.
As a containerd non-core sub-project, you will find the:

information in our containerd/project repository.