I am running Jenkins in a docker container and Jenkins tries to run my maven build. As part of the build, the docker maven plugin instructs it to build a docker image.
I was able to solve the problem by combining elements of both upvoted answers.
Set options to use different port in /etc/default/docker
.
DOCKER_OPTS="-H tcp://127.0.0.1:4243"
Restart the Docker daemon.
sudo service docker restart
Then build your package.
export DOCKER_HOST=tcp://127.0.0.1:4243
mvn clean package docker:build