Skip to content

Commit

Permalink
Support publishing as Docker Engine managed plugin
Browse files Browse the repository at this point in the history
Signed-off-by: Olli Janatuinen <[email protected]>
  • Loading branch information
olljanat committed Oct 6, 2020
1 parent 8193d2e commit bac86e5
Show file tree
Hide file tree
Showing 6 changed files with 86 additions and 0 deletions.
1 change: 1 addition & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Up @@ -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 [email protected]: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
Expand Down
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"
}

0 comments on commit bac86e5

Please sign in to comment.