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 aconfig.json
). As I want to install/pull my plugin on many Docker host machines when commissioning them, I would like to avoiddocker plugin create
at all cost and instead stick withdocker plugin install ...
.