Maven error while dockerfile build

Hello @all,
i am new to docker.
while i am running my docker file getting below error:

 => ERROR [6/6] RUN mvn -f /myapp/pom.xml clean package -DskipTests                                                                                                                                           5.2s
------
[6/6] RUN mvn -f /myapp/pom.xml clean package -DskipTests:
3.675 [INFO] Scanning for projects...
4.102 Downloading from central: https://repo.maven.apache.org/maven2/org/springframework/boot/spring-boot-starter-parent/2.4.3/spring-boot-starter-parent-2.4.3.pom
5.148 [ERROR] [ERROR] Some problems were encountered while processing the POMs:
5.148 [FATAL] Non-resolvable parent POM for com.docker.example:DockerDemo:0.0.1-SNAPSHOT: Could not transfer artifact org.springframework.boot:spring-boot-starter-parent:pom:2.4.3 from/to central 
5.149 [ERROR] The build could not read 1 project -> [Help 1]
5.150 [ERROR]

Below is my Dockerfile instructions

FROM openjdk

WORKDIR /myapp

COPY . /myapp

COPY pom.xml .

COPY src ./src

RUN mvn --version

RUN mvn clean install -e

#RUN apt-get update && apt-get install maven -y

RUN mvn -f /myapp/pom.xml clean package -DskipTests

#COPY myapp/target/DockerDemo-0.0.1-SNAPSHOT.jar /myapp-service/DockerDemo-0.0.1-SNAPSHOT.jar

#WORKDIR /myapp-service

#RUN javac DockerDemo.java

#COPY DockerDemo-0.0.1-SNAPSHOT.jar /usr/src/myapp/DockerDemo-0.0.1-SNAPSHOT.jar

ENTRYPOINT ["java", "-jar", "target/DockerDemo-0.0.1-SNAPSHOT.jar"]

EXPOSE 8084

below is my pom file

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
	<modelVersion>4.0.0</modelVersion>
	<parent>
		<groupId>org.springframework.boot</groupId>
		<artifactId>spring-boot-starter-parent</artifactId>
		<version>2.4.3</version>
		<relativePath/> <!-- lookup parent from repository -->
	</parent>
	<groupId>com.docker.example</groupId>
	<artifactId>DockerDemo</artifactId>
	<version>0.0.1-SNAPSHOT</version>
	<name>DockerDemo</name>
	<description>Demo project for Spring Boot</description>
	<properties>
		<java.version>8</java.version>
	</properties>
	<dependencies>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-web</artifactId>
		</dependency>

		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-test</artifactId>
			<scope>test</scope>
		</dependency>
	</dependencies>

	<build>
		<plugins>
			<plugin>
				<groupId>org.springframework.boot</groupId>
				<artifactId>spring-boot-maven-plugin</artifactId>
			</plugin>
		</plugins>
	</build>

</project>

Kindly suggest. Thank you in advance!

Since it is a Maven error, how can we help? I mean I see com.docker.example:DockerDemo in the output, but it is still a Maven error. If you identify the Maven issue, we can help with for example why a file is missing if it does.

Thank you for your response @rimelek i solved the above issue.

Now i’m getting below error while building an image
PS D:\switchProd\DockerDemo> docker build -t docker-demo .
[+] Building 0.5s (1/1) FINISHED docker:default
=> [internal] load build definition from Dockerfile 0.1s
=> => transferring dockerfile: 732B 0.1s
ERROR: failed to solve: circular dependency detected on stage: builder

while i am using only builder stage here .Then why i am facing the issue? Kindly suggest !

below is my docker file.

FROM maven:openjdk as builder

WORKDIR /myapp

COPY . /myapp

COPY pom.xml .

COPY src ./src

RUN mvn --version

RUN mvn -f /myapp/pom.xml clean package -DskipTests

COPY --from=builder /myapp/target/DockerDemo-0.0.1-SNAPSHOT.jar /DockerDemo-0.0.1-SNAPSHOT.jar

ENTRYPOINT [“java”, “-jar”, “target/DockerDemo-0.0.1-SNAPSHOT.jar”]

EXPOSE 8084

causes:

remove:

Furthermore, please format your code according this post: