项目作者: juicedata

项目描述 :
Docker volume plugin for juicefs
高级语言: Go
项目地址: git://github.com/juicedata/docker-volume-juicefs.git
创建时间: 2018-04-30T00:13:04Z
项目社区:https://github.com/juicedata/docker-volume-juicefs

开源协议:

下载


Docker Volume Plugin for Juicefs

Build Status

Modified from https://github.com/vieux/docker-volume-sshfs

Usage

  1. docker plugin install juicedata/juicefs
  2. # JuiceFS Community Edition
  3. docker volume create -d juicedata/juicefs:latest -o name=$JFS_VOL -o metaurl=$JFS_META_URL jfsvolume
  4. docker run -it -v jfsvolume:/opt busybox ls /opt
  5. # JuiceFS Enterprise Edition
  6. docker volume create -d juicedata/juicefs:latest -o name=$JFS_VOL -o token=$JFS_TOKEN -o access-key=$JFS_ACCESSKEY -o secret-key=$JFS_SECRETKEY jfsvolume
  7. docker run -it -v jfsvolume:/opt busybox ls /opt

Development

Boot up vagrant environment

  1. vagrant up
  2. vagrant ssh

Inside vagrant

  1. export WORKDIR=~/go/src/docker-volume-juicefs
  2. mkdir -p $WORKDIR
  3. rsync -avz --exclude plugin --exclude .git --exclude .vagrant /vagrant/ $WORKDIR/
  4. cd $WORKDIR
  5. make
  6. make enable
  7. docker volume create -d juicedata/juicefs:next -o name=$JFS_VOL -o token=$JFS_TOKEN -o access-key=$JFS_ACCESSKEY -o secret-key=$JFS_SECRETKEY jfsvolume
  8. docker run -it -v jfsvolume:/opt busybox ls /opt

Docker swarm

Install juicedata/juicefs plugin on every worker node, otherwise service mounting JuiceFS volume will not be scheduled.

Use docker service to deploy to Docker swarm

  1. docker service create --name nginx --mount \
  2. type=volume,volume-driver=juicedata/juicefs,source=jfsvolume,destination=/jfs,\
  3. volume-opt=name=$JFS_VOL,volume-opt=token=$JFS_TOKEN,volume-opt=access-key=$JFS_ACCESSKEY,volume-opt=secret-key=$JFS_SECRETKEY nginx:alpine

Scale up

  1. docker service scale nginx=3

Deployment from docker compose file is not supported because there is no way to pass volume options.

Debug

Enable debug information

  1. docker plugin disable juicedata/juicefs:latest
  2. docker plugin set juicedata/juicefs:latest DEBUG=1
  3. docker plugin enable juicedata/juicefs:latest

To quickly test out HEAD version:

  1. docker plugin disable juicedata/juicefs:latest
  2. CC=/usr/bin/musl-gcc go build -o bin/docker-volume-juicefs --ldflags '-linkmode external -extldflags "-static"' .
  3. mv bin/docker-volume-juicefs /var/lib/docker/plugins/3dea603741f58726d65b273d095f2bc01d1a1c8954a5498f5592041df8cdcd6c/rootfs
  4. docker plugin enable juicedata/juicefs:latest

The stdout of the plugin is redirected to dockerd log. The entries have a plugin=<ID> suffix.

runc, the default docker container runtime can be used to collect juicefs log

  1. # runc --root /run/docker/plugins/runtime-root/plugins.moby list
  2. ID PID STATUS BUNDLE
  3. 452d2c0cf3fd45e73a93a2f2b00d03ed28dd2bc0c58669cca9d4039e8866f99f 3672 running /run/docker/containerd/...
  4. # runc --root /run/docker/plugins/runtime-root/plugins.moby exec 452d2c0cf3fd45e73a93a2f2b00d03ed28dd2bc0c58669cca9d4039e8866f99f cat /var/log/juicefs.log
  5. umount: can't unmount /jfs/volumes/ci-aliyun: Invalid argument
  6. Unable to connect to local syslog daemon
  7. 2018/05/07 13:56:19.752864 <INFO>: Cache dir: /var/jfsCache/ci-aliyun limit: 1024 MB
  8. 2018/05/07 13:56:19.756331 <INFO>: Found 0 cached blocks (0 bytes)
  9. 2018/05/07 13:56:20.913240 <INFO>: mount successfully, st_dev: 48

NOTE: the directory for plugin runtime could be moby-plugins in some version of Docker.