Jib을 사용하여 dockerhub에 이미지 푸시

소개



Jib이란?

Maven, Gradle의 플러그인으로 정의하고 Docker 데몬을 사용하지 않고 Docker 이미지를 만들고 레지스트리에 푸시 할 수있는 도구

빠진 곳도 쓰면서 순서를 설명한다
빠는 1 : 프록시
빠는 2 : 인증

환경



OS : Windows
IDE : eclipse
build : Maven
jib-maven-plugin : 1.0.2

전제



dockerhub 계정이 있음
Repository를 만들어 두는 것 (이번에는 test라는 이름으로 갔다)

적당한 Maven 프로젝트를 떨어뜨린다



뭐든지 좋아. 자신은 다음을 떨어뜨렸다.
htps : // 기주 b. 이 m / sp 린 g-gui에서 s / gs - st-s r ゔ ぃ 세. 기 t

pom.xml 편집



pom.xml
<build>
    <plugins>
・・・
        <plugin>
            <groupId>com.google.cloud.tools</groupId>
            <artifactId>jib-maven-plugin</artifactId>
            <version>1.0.2</version>
            <configuration>
                <to>
                    <image>registry.hub.docker.com/{dockerhubId}/test</image>
                </to>
            </configuration>
        </plugin>
    </plugins>
</build>

DockerHub 원격 레지스트리에 Push


$ mvn compile jib:build
이클립스로

에서 실행

오류!


[ERROR] Failed to execute goal com.google.cloud.tools:jib-maven-plugin:1.0.2:build (default-cli) on project gs-rest-service: 縺昴?ョ繧医≧縺ェ繝帙せ繝医?ッ荳肴?弱〒縺吶?? (gcr.io): Unknown host 縺昴?ョ繧医≧縺ェ繝帙せ繝医?ッ荳肴?弱〒縺吶?? (gcr.io) -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

proxy를 통해 다시 DockerHub 원격 레지스트리에 Push


$ mvn -Dhttps.proxyHost=・・・ -Dhttps.proxyPort=・・・ -Dhttp.proxyHost=・・・ -Dhttp.proxyPort=・・・ compile jib:build이클립스로

에서 실행

오류!


[ERROR] Failed to execute goal com.google.cloud.tools:jib-maven-plugin:1.0.2:build (default-cli) on project gs-rest-service: Build image failed, perhaps you should set a credential helper name with the configuration '<to><credHelper>' or set credentials for 'registry.hub.docker.com' in your Maven settings: Unauthorized for registry.hub.docker.com/{dockerhubId}/test: 401 Unauthorized
[ERROR] {"errors":[{"code":"UNAUTHORIZED","message":"authentication required","detail":[{"Type":"repository","Class":"","Name":"{dockerhubId}/test","Action":"pull"},{"Type":"repository","Class":"","Name":"{dockerhuId}/test","Action":"push"}]}]}
[ERROR] -> [Help 1]

인증 설정



pom.xml
<build>
    <plugins>
・・・
        <plugin>
            <groupId>com.google.cloud.tools</groupId>
            <artifactId>jib-maven-plugin</artifactId>
            <version>1.0.2</version>
            <configuration>
                <to>
                    <image>registry.hub.docker.com/{dockerhubId}/test</image>
                    <auth>
                        <username>{dockerhubId}</username>
                        <password>{password}</password>
                    </auth>
                </to>
            </configuration>
        </plugin>
    </plugins>
</build>

다시 DockerHub 원격 레지스트리에 Push



만든 바람
[INFO] --- jib-maven-plugin:1.0.2:build (default-cli) @ gs-rest-service ---
[INFO] 
[INFO] Containerizing application to [36m{dockerhubid}/test[0m...
[INFO] Retrieving registry credentials for registry.hub.docker.com...
[INFO] Getting base image gcr.io/distroless/java:8...
[INFO] Building dependencies layer...
[INFO] Building resources layer...
[INFO] Building classes layer...
[INFO] 
[INFO] Container entrypoint set to [java, -cp, /app/resources:/app/classes:/app/libs/*, hello.Application]
[INFO] 
[INFO] Built and pushed image as [36m{dockerhubid}/test[0m
[INFO] 
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 11.279 s
[INFO] Finished at: 2019-03-19T14:48:47+09:00
[INFO] ------------------------------------------------------------------------

dockerhub에도 등록되어 있는지 확인

참고 링크



Jib

좋은 웹페이지 즐겨찾기