jetbrains/teamcity-agent docker unable to set agent to use java 11 inside of java 1.8


I have been trying to create an agent that will be able to use openjdk-11 instead of openjk-1.8. I downloaded the "jetbrains/teamcity-agent:latest" image from the docker hub for ubuntu 20.04 and ran the following script:

docker run -rm -it --name teamcity-agent-instance \
-e SERVER_URL="<server-url>" \
-v /mnt/f/teamcity/project/agent:/data/teamcity_agent/conf/ \

After running this I then entered the docker container with the following:

docker exec -it -u root teamcity-agent-instance bash

I then proceeded to install openjdk-11 which is saved in the path "/usr/lib/jvm/java-11-openjdk-amd64". Once this was installed, I committed a new docker image based off this container called "jetbrains/teamcity-agent:java11".

When I started the new image as an agent, it still reverted to using openjdk-1.8. I checked inside the new container instance and openjdk-11 was still there. I wondered if there was a way to add something to the "" file that is shared between the docker container and my host machine. I tried


But again it still said that it was using openjdk-1.8. Could this be that I am trying to use / set the wrong env.XXXX variable in the properties file or is this not the correct way to do this?

The only way I have managed to get the agent to use openjdk-11 is to enter the running container and delete "/opt/java". But this doesn't feel like the correct solution in the event that I want the agent to keep its java8 version. Also, if I do this method then the JAVA_HOME variables are not correctly set.

Any advice would be greatly appreciated!



It looks like you can specify your openjdk11 installation by including the TEAMCITY_JRE="/usr/lib/jvm/java-11-openjdk-amd64" or JRE_HOME="/usr/lib/jvm/java-11-openjdk-amd64" environment variable in your docker run command. See below for reference:

 docker run -rm -it --name teamcity-agent-instance \
-e SERVER_URL="<server-url>" \
-e TEAMCITY_JRE="/usr/lib/jvm/java-11-openjdk-amd64" \
-v /mnt/f/teamcity/project/agent:/data/teamcity_agent/conf/ \

Upgrading Java on the docker images will typically follow the same instructions described in our documentation here:


Hi Eric,

Thank you for your reply. I will give this a go in the next couple of days and update you if you this worked for me!

Can I confirm that I only need to be setting the JRE_HOME variable and not the JAVA_HOME / TEAMCITY_JRE? And if so, will this still allow MAVEN and its respective paths to be accessed when the agent accepts a task that is a maven goal?



It is actually preferable to use the TEAMCITY_JRE environment variable and I updated my previous response with this in mind. 

The TeamCity Agent selects the Java to run the server process as follows:

  • By default, if your TeamCity installation has a bundled JRE, it will be used to run the TeamCity server process. To use a different JRE, specify its path via the TEAMCITY_JRE environment variable.
  • If there is no bundled JRE present, the agent looks for the JRE_HOME or JAVA_HOME environment variable pointing to the installation directory of JRE or JVM (Java SDK) respectively. If both variables are declared, JRE will be used.

Please sign in to leave a comment.