Push the image to docker hub using Jib

Introduction

What is Jib jib_01.png A tool that can be defined as a Maven or Gradle plugin, create a Docker image without using the Docker daemon, and push it to the registry.

Explain the procedure while writing the addictive part Addictive 1: proxy Addiction 2: Authentication

environment

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

Premise

Have a docker hub account Create a Repository (this time I did it with the name test)

Drop a suitable Maven project

anything is fine. I dropped the following https://github.com/spring-guides/gs-rest-service.git

Edit 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>

Push to DockerHub remote registry

build



 For eclipse
 ![jib_02.png](https://qiita-image-store.s3.amazonaws.com/0/39442/bcdebe89-53ba-6489-c5d1-cca29dd10768.png)
 Run on

## error!

[ERROR] Failed to execute goal com.google.cloud.tools:jib-maven-plugin:1.0.2:build (default-cli) on project gs-rest-service:Subaru?Medical doctor ≧?荳 肴?Weak 〒?? (gcr.io): Unknown hostSubaru?Medical doctor ≧?荳 肴?Weak 〒?? (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


## Push again to Docker Hub remote registry through proxy

#### **`$ mvn -Dhttps.proxyHost=・ ・ ・-Dhttps.proxyPort=・ ・ ・-Dhttp.proxyHost=・ ・ ・-Dhttp.proxyPort=・ ・ ・compile jib:build`**

For eclipse jib_03.png Run on

error!

[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]

Set up authentication

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>

Push to Docker Hub remote registry again

The wind

[INFO] --- jib-maven-plugin:1.0.2:build (default-cli) @ gs-rest-service ---
[INFO] 
[INFO] Containerizing application to {dockerhubid}/test...
[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 {dockerhubid}/test
[INFO] 
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 11.279 s
[INFO] Finished at: 2019-03-19T14:48:47+09:00
[INFO] ------------------------------------------------------------------------

Confirm that it is also registered in docker hub

Reference link

Jib

Recommended Posts

Push the image to docker hub using Jib
[GCP] Until you push the local Docker image to the Container Registry
Push the Docker Image distributed by Docker Hub to Google Container Registry and start the VM based on that Image
Steps to push Docker image to GitHub Container Registry (ghcr.io)
Command to try using Docker for the time being
multi-project docker build using jib
I can't find the docker image after updating to docker desktop 2.4.0.0
I tried to build the environment little by little using docker
[Personal notes] How to push a Docker image to GitHub Packages
Migrate Docker image to another server
How to build CloudStack using Docker
I tried to integrate Docker and Maven / Netbean nicely using Jib
Minimal Workflow to push Docker image to Github Container Registry with Github Actions
Set up a Wordpress Docker environment without using the Worpdress image
How to solve the problem that you can not pull image from docker hub with Minikube
Let's specify the version when using docker
Docker push to GitHub Container Registry (ghcr.io)
Investigate the replacement from Docker to Podman.
Proxy server with squid using docker image
How to implement image posting using rails
[Swift] How to set an image in the background without using UIImageView.
Try adding text to an image in Scala using the Java standard library
When I pushed to Docker Hub, I got requested access to the resource is denied
Volume of optimizing Hyper-v to eliminate the tightness of disk capacity (engineer using Docker)
Up to the point of launching a Docker container built using RedHat Quarkus
A note when I'm addicted to using Docker Hub Vault in server mode
A quick note on using jshell with the official Docker image of the JDK
I tried using Docker for the first time
I tried to verify AdoptOpenJDK 11 (11.0.2) with Docker image
How to check the logs in the Docker container
How to make Spring Boot Docker Image smaller
How to implement the breadcrumb function using gretel
Flow to implement image posting function using ActiveStorage
How to give your image to someone with docker
Introduce docker to the application you are creating
Change the location folder of Docker image & container
I tried using Wercker to create and publish a Docker image that launches GlassFish 5.
I built an environment to execute unit tests using Oracle database (oracle12c) on the Docker in Docker (dind) image of GitLab-CI.
Continued ・ Flow to implement image posting function using ActiveStorage
[Road _node.js_1-1] Road to build Node.js Express MySQL environment using Docker
I tried using the Server Push function of Servlet 4.0
How to figure out how much disk Docker is using
How to deploy to Heroku from a local docker image
I tried to summarize the state transition of docker
How to move to the details screen by clicking the image
I want to judge the range using the monthly degree
Run the Android emulator on Docker using Android Emulator Container Scripts
Mandels to create an image of the Mandelbrot set
Write byte array image data to outputstream using ImageIO
I want to call the main method using reflection
How to judge the click of any area of the image
Try to build a Java development environment using Docker
The first step to using Xib instead of StoryBoard
Push Docker images from GitHub Actions to GitHub Container Registry
[Rails] How to display an image in the view
I tried to build an environment using Docker (beginner)
The story of pushing a Docker container to GitHub Package Registry and Docker Hub with GitHub Actions
If you want to make a Java application a Docker image, it is convenient to use jib.