Maven stucks on building an image for docker.io of my Spring Boot application

I am learning Docker and try to build one of my first images not according Docker docs. I heard spring-boot-maven-plugin can build images specifically for docker.
So I just opened MINGW64 terminal and navigated to my Spring Boot project root directory that has pom.xml.
I have tested whether my application works in a production mode when working directory is \target\. Website runs on tomcat.
So I just launched command mvn spring-boot:build-image
And maven started to build an image. But it did not finished. It stucked onto [INFO] Building image 'docker.io/library/maitinimas01image:latest' process.

I need help. maybe any of you know what is wrong and how can I build an image? Docker Desktop version 4.16.2 (95914) is running. When I open an extra console and type command docker --version I do not get any response. Process is also stuck. I have to end with ctrl+c.

I tried to launch maven in debug mode ... -X ...
and look at the terminal window:

This is a screen of stuck image building process. Do you know what is going on?
How to solve it?

1 Like

Having the same issue and also I am new to docker. While saving the image it just hangs and stay like this forever. On the other hand, on creating a new application without dependencies, it saves the image successfully. Wondering what is going on here!

There are new ways of building images. You have to build images separately for React then for Spring Boot and also for database. React and Spring Boot must have Dockerfile’s inside. And 1 folder higher - root folder that contains frontend and backend there should be docker-compose.yml.
Check this out: Deploying a React Spring Boot App with Docker Part I - YouTube
Dude on YouTube shows how to do it right.

I don’t have any heavy application. Just simple microservice built using Spring boot with no front end.
Still its hanging while saving image.

Just added dependency in pom.xml file with details of image name.

<build>
	<plugins>
		<plugin>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-maven-plugin</artifactId>
			<configuration>
			    <image>
			         <name>sumittambat/currency-exchange-${project.artifactId}:${project.version}</name>
			    </image>
			    <pullPolicy>IF_NOT_PRESENT</pullPolicy>
			</configuration>
		</plugin>
	</plugins>
</build>

Snippet of Log:
[INFO] [creator] Setting default process type ‘web’
[INFO] [creator] Saving docker.io/sumittambat/currency-exchange-currency-exchange:0.0.1-SNAPSHOT

Please guide me to solve this issue.

Regards,
Sumit

I solved the issue somehow by adding docker.io before the image name, like in your case try this:
docker.io/sumittambat/currency-exchange-${project.artifactId}:${project.version} (don’t forget to run mvn clean install once done editing your pom.xml file)
Also if possible try cleaning your docker daemon or resetting to factory defaults, this worked for me.