Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support publishing as Docker Engine managed plugin #96

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -8,3 +8,4 @@ jobs:
- checkout
- run: make circleci
- run: sudo make test
- run: make -f plugin/Makefile create
3 changes: 3 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
*
!/plugin/
!/docker-lvm-plugin
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -9,7 +9,10 @@ This plugin can be used to create lvm volumes of specified size, which can
then be bind mounted into the container using `docker run` command.

## Setup
### Using Docker
docker plugin install --alias lvm containers/docker-lvm-plugin/docker-lvm-plugin VOLUME_GROUP=vg0

### Manual
1) git clone git@github.com:projectatomic/docker-lvm-plugin.git (You can also use HTTPS to clone: git clone https://github.com/projectatomic/docker-lvm-plugin.git)
2) cd docker-lvm-plugin
3) export GO111MODULE=on
4 changes: 4 additions & 0 deletions plugin/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
FROM alpine
RUN apk update && apk add lvm2 xfsprogs cryptsetup thin-provisioning-tools
RUN mkdir -p /var/lib/docker-lvm-plugin
COPY docker-lvm-plugin /
39 changes: 39 additions & 0 deletions plugin/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name := containers/docker-lvm-plugin

.PHONY: build
build: docker-lvm-plugin

docker-lvm-plugin: main.go driver.go utils.go go.mod go.sum
docker run --rm --tmpfs /tmp -v $(shell pwd):/tmp/docker-lvm-plugin -w /tmp/docker-lvm-plugin golang:latest go build

.PHONY: create
create: plugin/config.json plugin/rootfs
docker plugin rm --force $(name) || true
docker plugin create $(name) plugin

.PHONY: install
install: create
docker plugin rm --force $(name) || true
docker plugin install $(name) --grant-all-permissions

.PHONY: push
push: create
docker plugin push $(name)

.PHONY: enable
enable: create
docker plugin enable $(name)

.PHONY: clean
clean:
rm -rf plugin

plugin/rootfs: .dockerignore plugin/Dockerfile docker-lvm-plugin
docker build --tag $(name):rootfs -f plugin/Dockerfile .
docker rm --force --volumes rootfs || true
docker create --name rootfs $(name):rootfs
rm -rf $@
mkdir -p $@
docker export rootfs | tar -x -C $@
docker rm --force --volumes rootfs

36 changes: 36 additions & 0 deletions plugin/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"Description": "LVM volume plugin for Docker",
"Documentation": "https://docs.docker.com/engine/extend/plugins/",
"Entrypoint": ["/docker-lvm-plugin"],
"Env": [
{
"Name": "VOLUME_GROUP",
"Description": "LVM volume group to create volumes in.",
"Settable": ["value"],
"Value": null
}
],
"Interface": {
"Socket": "lvm.sock",
"Types": ["docker.volumedriver/1.0"]
},
"Linux": {
"Capabilities": ["CAP_SYS_ADMIN"],
"AllowAllDevices": true,
"Devices": null
},
"Mounts": [
{
"description": "Device access for devicemapper (/dev/mapper/*, /dev/*/*)",
"destination": "/dev",
"options": ["rbind"],
"name": "dev",
"source": "/dev",
"type": "bind"
}
],
"Network": {
"Type": "host"
},
"PropagatedMount": "/var/lib/docker-lvm-plugin"
}