docker-maven-plugin
docker-maven-plugin copied to clipboard
Support for Docker contexts, or a Docker socket in an alternative location
Description
I'm using Colima to run Docker containers on macOS and pulling and running images via the docker
CLI tool works just fine. Colima created and activated a Docker context with a socket in $HOME/.colima/default/docker.sock
:
❯ docker context ls
NAME DESCRIPTION DOCKER ENDPOINT KUBERNETES ENDPOINT ORCHESTRATOR
colima * colima unix:///Users/nbreunese/.colima/default/docker.sock
default Current DOCKER_HOST based configuration unix:///var/run/docker.sock https://35.204.107.135 (default) swarm
rancher-desktop Rancher Desktop moby context unix:///Users/nbreunese/.rd/docker.sock
It seems that docker-maven-plugin
does not find or use this Docker context, because when I run a Maven project which uses docker-maven-plugin
I get the following error:
No <dockerHost> given, no DOCKER_HOST environment variable, no read/writable '/var/run/docker.sock' or '//./pipe/docker_engine' and no external provider like Docker machine configured
According to the Global Configuration section in the documentation, docker-maven-plugin
checks /var/run/docker.sock
on macOS, but I don't see mention of support for Docker contexts. Does docker-maven-plugin
support Docker contexts? If not, could this be added? If it does, it does not seem to work for me. In that case, is there a way to specify a local Docker socket via the DOCKER_HOST
environment variable?
Info
- docker-maven-plugin version : 0.40.1
- Maven version (
mvn -v
) : 3.8.6
- Docker version :
❯ docker version
Client:
Version: 20.10.14
API version: 1.41
Go version: go1.18.1
Git commit: 0a7772e
Built: Tue May 03 01:09:34 2022
OS/Arch: darwin/amd64
Context: colima
Experimental: true
Server:
Engine:
Version: 20.10.11
API version: 1.41 (minimum version 1.12)
Go version: go1.16.15
Git commit: 847da184ad5048b27f5bdf9d53d070f731b43180
Built: Wed Apr 13 23:41:08 2022
OS/Arch: linux/amd64
Experimental: false
containerd:
Version: v1.5.8
GitCommit: 1e5ef943eb76627a6d3b6de8cd1ef6537f393a71
runc:
Version: 1.0.0-rc95
GitCommit: b9ee9c6314599f1b4a7f497e1f1f856fe433d3b7
docker-init:
Version: 0.19.0
GitCommit:
- If it's a bug, how to reproduce : Run Colima and then a Maven build with
docker-maven-plugin
- If it's a feature request, what is your use case : Using
docker-maven-plugin
that works with Colima (and other tools that don't put the Docker socket at/var/run/docker.sock
. - Sample project : Any project that uses
docker-maven-plugin
You are correct, dmp doesn't support Docker contexts, but does it work if you set the environment variable DOCKER_HOST to "unix:///Users/nbreunese/.colima/default/docker.sock" (or alternatively the <dockerHost>
plugin configuration variable) ?
Setting DOCKER_HOST
like that indeed works, thanks! It would still be nice if docker-maven-plugin
would add support for Docker contexts, but I can use this as a workaround for now.