我必须创建一个 docker 映像,从一个 distroless 基础映像开始,并带有一些自定义文件。我在我的 Spring Boot 项目中使用 JIB 和 maven。我正在使用 Docker 工具箱在 Windows 7 上工作。这是我现在要做的步骤:
1)使用这些条目创建Dockerfile :
FROM gcr.io/distroless/java:8
COPY known_hosts ~/.ssh/known_hosts
EXPOSE 8888
2)执行命令:
docker build -t conf_server_image .
3) 在 pom.xml 上添加以下行:
<plugin>
<groupId>com.google.cloud.tools</groupId>
<artifactId>jib-maven-plugin</artifactId>
<version>2.1.0</version>
<configuration>
<from>
<image>conf_server_image:latest</image>
</from>
<to>
<image>${project.artifactId}:${project.version}</image>
</to>
<container>
<jvmFlags>
<jvmFlag>-Xms512m</jvmFlag>
<jvmFlag>-Xmx512m</jvmFlag>
</jvmFlags>
</container>
</configuration>
</plugin>
4)执行命令(使用我的 docker.io 的 ID 和密码):
docker login
4)执行构建命令
mvnw clean compile jib:dockerBuild
但该过程返回我这个错误:
[INFO] Executing tasks:
[INFO] [============ ] 40,0% complete
[INFO] > building image to Docker daemon
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 12.941 s
[INFO] Finished at: 2020-04-10T11:26:59+02:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal com.google.cloud.tools:jib-maven-plugin:2.1.0:dockerBuild (default-cli) on project sirio-configuration-server: Build to Docker daemon failed, pe
haps you should make sure your credentials for 'registry-1.docker.io/library/conf_server_image' are set up correctly. See https://github.com/GoogleContainerTools/jib/blob/mast
r/docs/faq.md#what-should-i-do-when-the-registry-responds-with-unauthorized for help: Unauthorized for registry-1.docker.io/library/conf_server_image: 401 Unauthorized
[ERROR] {"errors":[{"code":"UNAUTHORIZED","message":"authentication required","detail":[{"Type":"repository","Class":"","Name":"library/conf_server_image","Action":"pull"}]}]}
[ERROR] -> [Help 1]
[ERROR]
我忘记了什么?谢谢