Skip to content

Commit bac86e5

Browse files
committed
Support publishing as Docker Engine managed plugin
Signed-off-by: Olli Janatuinen <olli.janatuinen@gmail.com>
1 parent 8193d2e commit bac86e5

File tree

6 files changed

+86
-0
lines changed

6 files changed

+86
-0
lines changed

.circleci/config.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@ jobs:
88
- checkout
99
- run: make circleci
1010
- run: sudo make test
11+
- run: make -f plugin/Makefile create

.dockerignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
*
2+
!/plugin/
3+
!/docker-lvm-plugin

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,10 @@ This plugin can be used to create lvm volumes of specified size, which can
99
then be bind mounted into the container using `docker run` command.
1010

1111
## Setup
12+
### Using Docker
13+
docker plugin install --alias lvm containers/docker-lvm-plugin/docker-lvm-plugin VOLUME_GROUP=vg0
1214

15+
### Manual
1316
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)
1417
2) cd docker-lvm-plugin
1518
3) export GO111MODULE=on

plugin/Dockerfile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
FROM alpine
2+
RUN apk update && apk add lvm2 xfsprogs cryptsetup thin-provisioning-tools
3+
RUN mkdir -p /var/lib/docker-lvm-plugin
4+
COPY docker-lvm-plugin /

plugin/Makefile

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name := containers/docker-lvm-plugin
2+
3+
.PHONY: build
4+
build: docker-lvm-plugin
5+
6+
docker-lvm-plugin: main.go driver.go utils.go go.mod go.sum
7+
docker run --rm --tmpfs /tmp -v $(shell pwd):/tmp/docker-lvm-plugin -w /tmp/docker-lvm-plugin golang:latest go build
8+
9+
.PHONY: create
10+
create: plugin/config.json plugin/rootfs
11+
docker plugin rm --force $(name) || true
12+
docker plugin create $(name) plugin
13+
14+
.PHONY: install
15+
install: create
16+
docker plugin rm --force $(name) || true
17+
docker plugin install $(name) --grant-all-permissions
18+
19+
.PHONY: push
20+
push: create
21+
docker plugin push $(name)
22+
23+
.PHONY: enable
24+
enable: create
25+
docker plugin enable $(name)
26+
27+
.PHONY: clean
28+
clean:
29+
rm -rf plugin
30+
31+
plugin/rootfs: .dockerignore plugin/Dockerfile docker-lvm-plugin
32+
docker build --tag $(name):rootfs -f plugin/Dockerfile .
33+
docker rm --force --volumes rootfs || true
34+
docker create --name rootfs $(name):rootfs
35+
rm -rf $@
36+
mkdir -p $@
37+
docker export rootfs | tar -x -C $@
38+
docker rm --force --volumes rootfs
39+

plugin/config.json

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
{
2+
"Description": "LVM volume plugin for Docker",
3+
"Documentation": "https://docs.docker.com/engine/extend/plugins/",
4+
"Entrypoint": ["/docker-lvm-plugin"],
5+
"Env": [
6+
{
7+
"Name": "VOLUME_GROUP",
8+
"Description": "LVM volume group to create volumes in.",
9+
"Settable": ["value"],
10+
"Value": null
11+
}
12+
],
13+
"Interface": {
14+
"Socket": "lvm.sock",
15+
"Types": ["docker.volumedriver/1.0"]
16+
},
17+
"Linux": {
18+
"Capabilities": ["CAP_SYS_ADMIN"],
19+
"AllowAllDevices": true,
20+
"Devices": null
21+
},
22+
"Mounts": [
23+
{
24+
"description": "Device access for devicemapper (/dev/mapper/*, /dev/*/*)",
25+
"destination": "/dev",
26+
"options": ["rbind"],
27+
"name": "dev",
28+
"source": "/dev",
29+
"type": "bind"
30+
}
31+
],
32+
"Network": {
33+
"Type": "host"
34+
},
35+
"PropagatedMount": "/var/lib/docker-lvm-plugin"
36+
}

0 commit comments

Comments
 (0)