Dockerfile-maven: Cannot build without Internet connection

Created on 7 May 2018  路  2Comments  路  Source: spotify/dockerfile-maven

We're working in an air-gapped environment without Internet access.

To make docker work we set up an internal docker repository with the required images and added its URI in 'registry_mirrors' and 'insecure_registries' (it is on HTTP only) properties in /etc/docker/daemon.json.

With this configuration in place we can successfully build the image with 'docker build'.

Trying to build from the same Dockerfile with dockerfile-maven plugin we get the following exception.
It seems that the docker client is trying to use the public registry for some reason, and that obviously fails in our environment.

[INFO] --- dockerfile-maven-plugin:1.4.0:build (default) @ kafka ---
[INFO] Building Docker context /home/user/src/project
[INFO] 
[INFO] Image will be built as my-ns/project:latest
[INFO] 
[INFO] Step 1/5 : FROM openjdk:8-jdk-alpine
[INFO] 
[ERROR] Get https://registry-1.docker.io/v2/: dial tcp: lookup registry-1.docker.io on 192.168.1.1:53: server misbehaving
[WARNING] An attempt failed, will retry 1 more times
org.apache.maven.plugin.MojoExecutionException: Could not build image
              at com.spotify.plugin.dockerfile.BuildMojo.buildImage(BuildMojo.java:185)
              at com.spotify.plugin.dockerfile.BuildMojo.execute(BuildMojo.java:105)
              at com.spotify.plugin.dockerfile.AbstractDockerMojo.tryExecute(AbstractDockerMojo.java:246)
              at com.spotify.plugin.dockerfile.AbstractDockerMojo.execute(AbstractDockerMojo.java:235)
              at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
              at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:207)
              at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
              at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
              at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
              at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
              at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
              at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
              at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307)
              at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)
              at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)
              at org.apache.maven.cli.MavenCli.execute(MavenCli.java:863)
              at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:288)
              at org.apache.maven.cli.MavenCli.main(MavenCli.java:199)
              at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
              at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
              at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
              at java.lang.reflect.Method.invoke(Method.java:498)
              at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
              at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
              at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
              at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
              at org.codehaus.classworlds.Launcher.main(Launcher.java:47)
Caused by: com.spotify.docker.client.exceptions.DockerException: Get https://registry-1.docker.io/v2/: dial tcp: lookup registry-1.docker.io on 192.168.1.1:53: server misbehaving
              at com.spotify.plugin.dockerfile.LoggingProgressHandler.handleError(LoggingProgressHandler.java:105)
              at com.spotify.plugin.dockerfile.LoggingProgressHandler.progress(LoggingProgressHandler.java:63)
              at com.spotify.docker.client.DefaultDockerClient.build(DefaultDockerClient.java:1424)
              at com.spotify.docker.client.DefaultDockerClient.build(DefaultDockerClient.java:1383)
              at com.spotify.plugin.dockerfile.BuildMojo.buildImage(BuildMojo.java:178)
              ... 26 more

Most helpful comment

Setting pullNewerImage to false would be my suggestion on what to do here.

All 2 comments

Hey, I was with a similar problem.
I was trying to build a docker image with FROM referencing another local image.
I was getting

Caused by: com.spotify.docker.client.exceptions.DockerException: pull access denied for 'from_image', repository does not exist or may require 'docker login'

Looking at the source code I found the property <pullNewerImage>. Setting it to false solve my issue.

<pullNewerImage>false</pullNewerImage>

Setting pullNewerImage to false would be my suggestion on what to do here.

Was this page helpful?
0 / 5 - 0 ratings