在linux上docker内网环境部署,怎样阻止docker去外网拉取java镜像,而采用本地的已有镜像

Docker 未结 1 408
877713939
877713939 剑者 2023-11-08 13:54
悬赏:5

一、该问题的重现步骤是什么?

  1. 我已经把bladex/alpine-java:openjdk8-openj9_cn_slim拉取到docker里了,我执行的命令是docker pull bladex/alpine-java:openjdk8-openj9_cn_slim

  2. 内网环境下,centos7,docker部署,执行命令mvn dockerfile:build

  3. 这是dockerfile文件,在执行第一条的时候报错


    FROM bladex/alpine-java:openjdk8-openj9_cn_slim MAINTAINER bladejava@qq.com RUN mkdir -p /blade/camera WORKDIR /blade/camera EXPOSE 9002 COPY ./solib /usr/local/lib/ ENV LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH ADD ./target/blade-camera.jar ./app.jar ENTRYPOINT ["java", "-Djava.security.egd=file:/dev/./urandom", "-jar", "app.jar"] CMD ["--spring.profiles.active=test"]

  4. 这是执行命令后的报错信息


    [INFO] ---------------------< org.springblade:blade-auth >---------------------

    [INFO] Building blade-auth 3.0.1.RELEASE                                 [6/46]

    [INFO]   from blade-auth/pom.xml

    [INFO] --------------------------------[ jar ]---------------------------------

    [INFO] 

    [INFO] --- dockerfile:1.4.13:build (default-cli) @ blade-auth ---

    [INFO] dockerfile: null

    [INFO] contextDirectory: /usr/local/znxj/blade-auth

    [INFO] Building Docker context /usr/local/znxj/blade-auth

    [INFO] Path(dockerfile): null

    [INFO] Path(contextDirectory): /usr/local/znxj/blade-auth

    [INFO] 

    [INFO] Image will be built as 192.168.0.5/blade/blade-auth:3.0.1.RELEASE

    [INFO] 

    [INFO] Step 1/8 : FROM bladex/alpine-java:openjdk8-openj9_cn_slim

    [INFO] 

    [ERROR] Get "https://registry-1.docker.io/v2/": context deadline exceeded (Client.Timeout exceeded while awaiting headers)

    [WARNING] An attempt failed, will retry 1 more times

    org.apache.maven.plugin.MojoExecutionException: Could not build image




二、你期待的结果是什么?实际看到的又是什么?

我期待能够在内网环境下成功执行命令mvn dockerfile:build。

实际上我必须联网才能成功执行。

三、你正在使用的是什么产品,什么版本?在什么操作系统上?

bladex,在linux上

四、请提供详细的错误堆栈信息,这很重要。

[INFO] ---------------------< org.springblade:blade-auth >---------------------

[INFO] Building blade-auth 3.0.1.RELEASE                                 [6/46]

[INFO]   from blade-auth/pom.xml

[INFO] --------------------------------[ jar ]---------------------------------

[INFO] 

[INFO] --- dockerfile:1.4.13:build (default-cli) @ blade-auth ---

[INFO] dockerfile: null

[INFO] contextDirectory: /usr/local/znxj/blade-auth

[INFO] Building Docker context /usr/local/znxj/blade-auth

[INFO] Path(dockerfile): null

[INFO] Path(contextDirectory): /usr/local/znxj/blade-auth

[INFO] 

[INFO] Image will be built as 192.168.0.5/blade/blade-auth:3.0.1.RELEASE

[INFO] 

[INFO] Step 1/8 : FROM bladex/alpine-java:openjdk8-openj9_cn_slim

[INFO] 

[ERROR] Get "https://registry-1.docker.io/v2/": context deadline exceeded (Client.Timeout exceeded while awaiting headers)

[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:247)

    at com.spotify.plugin.dockerfile.BuildMojo.execute (BuildMojo.java:135)

    at com.spotify.plugin.dockerfile.AbstractDockerMojo.tryExecute (AbstractDockerMojo.java:265)

    at com.spotify.plugin.dockerfile.AbstractDockerMojo.execute (AbstractDockerMojo.java:254)

    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:126)

    at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute2 (MojoExecutor.java:342)

    at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute (MojoExecutor.java:330)

    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:213)

    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:175)

    at org.apache.maven.lifecycle.internal.MojoExecutor.access$000 (MojoExecutor.java:76)

    at org.apache.maven.lifecycle.internal.MojoExecutor$1.run (MojoExecutor.java:163)

    at org.apache.maven.plugin.DefaultMojosExecutionStrategy.execute (DefaultMojosExecutionStrategy.java:39)

    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:160)

    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:105)

    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:73)

    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:53)

    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:118)

    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:261)

    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:173)

    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:101)

    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:910)

    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:283)

    at org.apache.maven.cli.MavenCli.main (MavenCli.java:206)

    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:283)

    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:226)

    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:407)

    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:348)

Caused by: com.spotify.docker.client.exceptions.DockerException: Get "https://registry-1.docker.io/v2/": context deadline exceeded (Client.Timeout exceeded while awaiting headers)

    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$BuildProgressHandler.progress (DefaultDockerClient.java:312)

    at com.spotify.docker.client.ProgressStream.tail (ProgressStream.java:77)

    at com.spotify.docker.client.DefaultDockerClient$ResponseTailReader.call (DefaultDockerClient.java:2754)

    at com.spotify.docker.client.DefaultDockerClient$ResponseTailReader.call (DefaultDockerClient.java:2738)

    at java.util.concurrent.FutureTask.run (FutureTask.java:266)

    at java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1149)

    at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:624)

    at java.lang.Thread.run (Thread.java:750)

五、若有更多详细信息,请在下面提供。

1条回答
  • bladex/alpine-java:openjdk8-openj9_cn_slim这个镜像本地是没有的

    作者追问:2023-11-08 15:39

    我运行了这个命令:docker pull bladex/alpine-java:openjdk8-openj9_cn_slim
    然后运行:docker images
    看到列表中就有这个镜像了,这样不算本地有吗?

    作者追问:2023-11-08 15:52

    我是在联网的时候执行的docker pull bladex/alpine-java:openjdk8-openj9_cn_slim,成功拉下镜像到本地。随后切换到内网,部署失败的。

    请问如果这样不行,还有其他方式可以实现docker纯内网部署吗?我需要实现纯内网部署

    0 讨论(0)
提交回复