Has anyone got docker-maven-plugin working in drone?
The best solution I’ve been able to come up with is using appleboy/drone-ssh to shell into a host that has docker, maven, java installed and running it there. Is there a way that I can run mvn -Pdist clean package docker:build in the workspace? How are people building docker packages for java projects in drone?

Hi charlesmims,

Is there any other method to achieve same.

The question I have is, do you absolutely need to build the Docker image with a maven task?

Drone provides a plugin for building docker images [1]. So typically you would define a Dockerfile and let Drone handle building and publishing the Docker image. If you prefer to delegate the docker build process to maven, please note that you will have to use drone in a manner that is non-optimal. Let me explain …

Maven will need to connect with a running Docker daemon. This means you will need to expose the host machine Docker daemon to your build, for example:

    image: maven
      - mvn -Pdist clean package docker:build 
      - /var/run/docker.sock:/var/run/docker.sock

So why is this non-optimal? You will have to expose the host-machine Docker socket which has security implications, since you are effectively granting your pipeline root access to the host machine. Furthermore, over time, this operation will fill-up disk space and you will need to manually purge.

The benefit of using the Docker plugin with a Dockerfile is that Drone is able to build and publish your Docker image without exposing the host machine socket, and does not mutate the host machine in any way. In general, I recommend using the native Drone solution (Docker plugin) whenever possible.


Hey, I found this topic while trying to figure out how to migrate our circleci build to drone.

Basically, we do our docker image builds using the jib maven plugin. It makes clean consistent images that only change if the source changes. It also allows us to have multiple artifacts generated in our mvn package, rather than having to manage separate dockerfiles for everything.

Being clean and reproducible I really like this approach. Is there any way to keep this working?

Another issue we have with the docker isolation is that it makes running unit tests that depend on docker containers (e.g. using test-containers ) impossible. We do this a fair bit to test stuff that works with databases and the like with the db running on a temporary docker container)