0

I'm creating a Docker managed (network) plugin basically as follows; the concrete env var values shouldn't matter:

PLUGINNAME=foo
LOCAL_REGISTRY_PORT=11500

PLUGIN_IMAGE=localhost:${LOCAL_REGISTRY_PORT}/${PLUGINNAME}
PLUGIN_EXPORT=${PLUGINNAME}-plugin.tar.gz

# build plugin (intermediate) image
docker build -t ${PLUGINNAME}-plugin -f build/Dockerfile .

# export plugin rootfs
id=$(docker create ${PLUGINNAME}-plugin true)
sudo rm -rf plugin/rootfs
sudo mkdir -p plugin/rootfs
sudo docker export "$id" | sudo tar -x -C plugin/rootfs
docker rm -vf "$id"

# spin up a local image v2 registry
docker plugin rm -f ${PLUGIN_IMAGE} 2>/dev/null || true
docker plugin create ${PLUGIN_IMAGE} 2>/dev/null ./plugin
docker container stop registry 2>/dev/null || true
docker container rm -v registry 2>/dev/null || true
docker run -d -p ${LOCAL_REGISTRY_PORT}:5000 --restart=always --name registry registry:2 2>/dev/null
wget --quiet --waitretry=1 --tries=10 --retry-connrefused -O /dev/null http://localhost:${LOCAL_REGISTRY_PORT}/ 1>/dev/null

# push plugin into local registry
docker plugin push ${PLUGIN_IMAGE}

# export plugin image
skopeo copy --src-tls-verify=false docker://${PLUGIN_IMAGE} docker-archive:${PLUGIN_EXPORT}

This eventually gives me a foo-plugin.tar.gz image file.

Is there a way to directly install a managed Docker plugin from an exported image file? I tried importing the image file and then to docker plugin install foo-plugin:latest --alias foo, but this always fails as it tries to pull from a remote registry instead of consulting the locally imported image. Any ideas how to get this working without the need for a registry?

Please note: docker plugin create requires a local unpacked rootfs (together with a config.json). As I want to install/pull my plugin on many Docker host machines when commissioning them, I would like to avoid docker plugin create at all cost and instead stick with docker plugin install ....

TheDiveO
  • 2,183
  • 2
  • 19
  • 38
  • The [Docker plugin documentation](https://docs.docker.com/engine/extend/#creating-the-plugin) implies to me that `docker plugin create` installs the plugin from local files, with a directory containing a `config.json` and a `rootfs`. If you had a built image and `docker save`d it to a tar file, I'd expect that `docker load` and then `docker plugin install` wouldn't need a registry (similarly to `docker run`) but I haven't specifically tried this. – David Maze Oct 27 '22 at 10:16
  • `docker plugin create` requires a local unpacked rootfs (together with a `config.json`). As I want to install/pull this plugin on many Docker host machines when commissioning them, I would like to avoid `docker plugin create` at all cost and instead stick with `docker plugin install ...`. I've updated my Q to reflect this constraint. – TheDiveO Oct 27 '22 at 10:21
  • IIRM then the image manifest differs from an ordinary container image, thus the need for `docker push` and the whole shenanigan... – TheDiveO Oct 27 '22 at 14:07

0 Answers0