JDK 8 installed even though JDK 11 is mentioned in Dockerfile

I need to create a docker container for my app with JDK 11 installed. My docker file looks like below:

ARG env_=local
FROM openjdk:11-jdk
LABEL maintainer=myapp artifact=pro-web-admin
ENV ENV_NAME=$env_
EXPOSE 9090
ENV USER root
ADD build/libs/pro-web-admin-0.0.1-SNAPSHOT.jar pro-web-admin.jar
ENTRYPOINT ["java","-jar","/pro-web-admin.jar"]

And my docker-compose.yml looks like below:

version: '3.8'
services:
  postgresqldb:
    image: postgres
    ports:
      - "5432:5432"
    network_mode: host
    environment:
      - POSTGRES_PASSWORD=root
      - POSTGRES_USER=root
      - POSTGRES_DB=testdb
  app:
    container_name: pro-web-admin
    image: pro-web-admin
    build: ./
    ports:
      - "9090:9090"
    network_mode: host
    depends_on:
      - postgresqldb
    environment:
      - USER=root

But I’m still seeing JDK version 8 inside the docker container:

Am I missing something here? I don’t see any discrepancy in the configuration. Can anyone please point out what’s wrong here? Really appreciate your valuable suggestions. Thanks in advance!

Quick guess, which is better than nothing.

Thinking update-alternatives.

Thank you for the response. How to configure this in docker-compose.yml ?
Does this mean I can’t run JDK 11 app using docker compose?

Hmm, the problem is not originated in the base image:

me@docker~$ docker run -ti openjdk:11-jdk java -version
Unable to find image 'openjdk:11-jdk' locally
11-jdk: Pulling from library/openjdk
e4c3d3e4f7b0: Pull complete
101c41d0463b: Pull complete
8275efcd805f: Pull complete
751620502a7a: Pull complete
a59da3a7d0e7: Pull complete
9c0f1dffe039: Pull complete
474314d81831: Pull complete
Digest: sha256:d8af704f3022f5c44b4340c58e62313c706301915ec00291eec0749fc5378c3b
Status: Downloaded newer image for openjdk:11-jdk
openjdk version "11.0.9" 2020-10-20
OpenJDK Runtime Environment 18.9 (build 11.0.9+11)
OpenJDK 64-Bit Server VM 18.9 (build 11.0.9+11, mixed mode)

Your Dockerfile shows no indication of alteration of the java configuration either. No entrypoint scripts, thus no hidden actions.
What you observe is impossible with a fresh build image based on your Dockerfile.

Sure it is a fresh builld and not just an old image that happens to have the same name and tag?

update:

me@docker~$ docker run -ti openjdk:11-jdk cat /etc/os-release
PRETTY_NAME="Debian GNU/Linux 10 (buster)"
NAME="Debian GNU/Linux"
VERSION_ID="10"
VERSION="10 (buster)"
VERSION_CODENAME=buster
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"

The container you checked is based on Alpine and deffinitly not an image based on a current version of the base image, which is based on Debian.

Looks like a pebkac :grin:

You’re right.
I was referring to an old image for docker compose and that was the reason for JDK 8.
Thank you for point it out.