Dockerfile-maven: Build docker FROM local image

Created on 30 Jul 2017  路  5Comments  路  Source: spotify/dockerfile-maven

I have created several DockerFiles in a hiearchy of dependencies resulting in some of my DockerFile has a FROM from other Docker images on my pc.

Using vanilla I can do FROM my-first-dockerfile in my second DockerFile without a registry prefix. Docker looks for local images before trying to downloading it from public registries.

https://stackoverflow.com/questions/20481225/how-can-i-use-a-local-image-as-the-base-image-with-a-dockerfile#20501690

But dockerfile-maven-plugin seems to skip the step of looking locally I get "repository my-first-dockerfile not found: does not exist or no pull access".

I have worked around this by running a local registry using https://hub.docker.com/_/registry/ and change my FROMs to FROM localhost:5000/my-first-dockerfile

But is a way to make dockerfile-maven-plugin/dockerclient follow default behaviour?

Most helpful comment

You can set pullNewerImage to false in the plugin's configuration.

All 5 comments

You can set pullNewerImage to false in the plugin's configuration.

Thanks, that worked..

I did see this option but expected it to work like docker build --pull=true where you add the option to force a download - not add the option to force not to download...

Sorry to re-open, but apparently it's not working for me: I have a local image but setting pullNewerImage to false ends up producing:

[ERROR] Failed to execute goal com.spotify:dockerfile-maven-plugin:1.3.7:build (default) on project config: Could not build image: java.util.concurrent.ExecutionException: com.spotify.docker.client.shaded.javax.ws.rs.ProcessingException: org.apache.http.conn.HttpHostConnectException: Connect to localhost:2375 [localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1] failed: Connection refused (Connection refused) 

Obviously I don't have a local registry and I don't wish to have one....

@rlogiacco that error message sounds more like what you would see if the plugin was trying to communicate with the docker daemon using localhost:2375. What DOCKER_HOME are you using / where do you expect the daemon to be running?

I had an empty DOCKER_HOME, but I fixed it by setting to unix:///var/run/docker.sock...

Was this page helpful?
0 / 5 - 0 ratings