# Docker build issue

**URL:** <https://forums.docker.com/t/docker-build-issue/140220>\
**Category:** General\
**Tags:** docker, build\
**Created:** [March 8, 2024, 7:17am UTC](https://forums.docker.com/t/docker-build-issue/140220 "2024-03-08T07:17:11Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![jagatheesan027](https://avatars.discourse-cdn.com/v4/letter/j/9de053/32.png) [@jagatheesan027](https://forums.docker.com/u/jagatheesan027)\
**Post date:** [March 8, 2024, 7:17am UTC](https://forums.docker.com/t/docker-build-issue/140220/1 "2024-03-08T07:17:11Z")

</div>

I tried to build an image with openjdk:17 base image with git installed and maven:3.5.0 but it is failing to build the image and throwing error, shared the error message below. Can anyone help me to solve this issue?

> [2/6] RUN apt-get -y update && apt-get install -y git && rm -rf /var/lib/apt/lists/\*:  
> 0.202 /bin/sh: apt-get: command not found

* * *

## Dockerfile:6

5 |  
6 | \>\>\> RUN apt-get -y update &&   
7 | \>\>\> apt-get install -y git &&   
8 | \>\>\> rm -rf /var/lib/apt/lists/\*

| 9 |
| --- |
| ERROR: failed to solve: process “/bin/sh -c apt-get -y update && apt-get install -y git && rm -rf /var/lib/apt/lists/\*” did not complete successfully: exit code: 127 |

---

<div class="post-metadata">

**Author:** ![meyay](https://sea3.discourse-cdn.com/docker/user_avatar/forums.docker.com/meyay/32/34000_2.png) [@meyay](https://forums.docker.com/u/meyay)\
**Post date:** [March 8, 2024, 7:40am UTC](https://forums.docker.com/t/docker-build-issue/140220/2 "2024-03-08T07:40:13Z")

</div>

Can you share why you think apt-get should exist in the base image?

Furthermore, can you share how you identified that the base image actually is based on debian/ubuntu?

---

<div class="post-metadata">

**Author:** ![jagatheesan027](https://avatars.discourse-cdn.com/v4/letter/j/9de053/32.png) [@jagatheesan027](https://forums.docker.com/u/jagatheesan027)\
**Post date:** [March 8, 2024, 8:09am UTC](https://forums.docker.com/t/docker-build-issue/140220/3 "2024-03-08T08:09:14Z")

</div>

I used openjdk:17 so I thought it is Debian based image and I used ‘apt-get’

but when I run the openjdk17 image I found it is based on Oracle Linux Server

docker run -it openjdk:17 bash  
bash-4.4# cat /etc/os-release  
NAME=“Oracle Linux Server”  
VERSION=“8.5”  
ID=“ol”  
ID\_LIKE=“fedora”  
VARIANT=“Server”  
VARIANT\_ID=“server”  
VERSION\_ID=“8.5”  
PLATFORM\_ID=“platform:el8”  
PRETTY\_NAME=“Oracle Linux Server 8.5”  
ANSI\_COLOR=“0;31”  
CPE\_NAME=“cpe:/o:oracle:linux:8:5:server”  
HOME\_URL=“[https://linux.oracle.com/](https://linux.oracle.com/)”  
BUG\_REPORT\_URL=“[https://bugzilla.oracle.com/](https://bugzilla.oracle.com/)”

ORACLE\_BUGZILLA\_PRODUCT=“Oracle Linux 8”  
ORACLE\_BUGZILLA\_PRODUCT\_VERSION=8.5  
ORACLE\_SUPPORT\_PRODUCT=“Oracle Linux”  
ORACLE\_SUPPORT\_PRODUCT\_VERSION=8.5

Can you help me to install git in this image?  
I tried ‘apt-get’, ‘apk’ and ‘yum’ but none of these worked

---

<div class="post-metadata">

**Author:** ![bluenobly](https://avatars.discourse-cdn.com/v4/letter/b/f9ae1b/32.png) [@bluenobly](https://forums.docker.com/u/bluenobly)\
**Post date:** [March 8, 2024, 8:46am UTC](https://forums.docker.com/t/docker-build-issue/140220/4 "2024-03-08T08:46:46Z")

</div>

The image is based on Oracle Linux. It uses **yum** or **dnf**.

```auto
dnf install git -y

```

But you should use a different image. This image is officially deprecated.

Take a look at the deprecation notices under  
[https://hub.docker.com/\_/openjdk](https://hub.docker.com/_/openjdk)

And note the vulnerabilities under  
[https://hub.docker.com/layers/library/openjdk/17-jdk-oracle/images/sha256-98f0304b3a3b7c12ce641177a99d1f3be56f532473a528fda38d53d519cafb13](https://hub.docker.com/layers/library/openjdk/17-jdk-oracle/images/sha256-98f0304b3a3b7c12ce641177a99d1f3be56f532473a528fda38d53d519cafb13)

---

<div class="post-metadata">

**Author:** ![jagatheesan027](https://avatars.discourse-cdn.com/v4/letter/j/9de053/32.png) [@jagatheesan027](https://forums.docker.com/u/jagatheesan027)\
**Post date:** [March 8, 2024, 8:54am UTC](https://forums.docker.com/t/docker-build-issue/140220/5 "2024-03-08T08:54:58Z")

</div>

Thank you for your response now I used openjdk:11 and it is working fine

---

<div class="post-metadata">

**Author:** ![bluenobly](https://avatars.discourse-cdn.com/v4/letter/b/f9ae1b/32.png) [@bluenobly](https://forums.docker.com/u/bluenobly)\
**Post date:** [March 8, 2024, 9:18am UTC](https://forums.docker.com/t/docker-build-issue/140220/6 "2024-03-08T09:18:08Z")

</div>

All openjdk builds are deprecated see:

> <https://github.com/docker-library/openjdk/issues/505>
>
> Hi!
> 
> This is a heads-up that we are going to retire "\[OpenJDK Project Builds\](…https://adoptopenjdk.net/upstream.html)" for OpenJDK 11u and OpenJDK 8u. We plan to stop producing builds after the July 2022 CPU update (11.0.16 and 8u342 will be the last builds). Since we know that the docker library is using those for the \`docker.io/library/openjdk:11\` and \`docker.io/library/openjdk:8\` images, we wanted to give a heads-up that this is going to happen. Perhaps it would be best to remove the \`11\` and \`8\` tags (in October 2022, perhaps) as at that point these images would be out-of-date without recent security fixes. I see that the \`docker.io/library/openjdk:17\` tag points already to an outdated build (\`17.0.2\` over latest \`17.0.3\`).
> 
> We, Red Hat, have produced those builds as a service to the community for Linux x86\_64, Linux aarch64 and Windows x86\_64. Now with projects like \[Eclipse Adoptium\](https://projects.eclipse.org/projects/adoptium) which produce \[Eclipse Temurin\](https://adoptium.net/temurin/releases/) builds on a wider variety of platforms which are JCK tested there is a natural replacement for a vendor neutral OpenJDK build for the JDK 8 and JDK 11 code streams for the community to use. For the 17u code stream of the OpenJDK updates project the builds linked from the OpenJDK wiki are already Eclipse Temurin binaries and we'd like to make this consistent come October 2022.

> Now with projects like [Eclipse Adoptium](https://projects.eclipse.org/projects/adoptium) which produce [Eclipse Temurin](https://adoptium.net/temurin/releases/) builds on a wider variety of platforms which are JCK tested there is a natural replacement for a vendor neutral OpenJDK build for the JDK 8 and JDK 11 code streams for the community to use.

> Upstream binaries were built by Red Hat on their infrastructure and distributed by AdoptOpenJDK on behalf of the OpenJDK jdk8u and jdk11u community projects. The last releases produced by this method were 8u342 and 11.0.16 (July 2022 CPU update). This service is now provided by the Adoptium project, and users of upstream builds should now migrate to the equivalent Eclipse Temurin releases.
