How to upgrade JDK in Docker compose TeamCity container?

I have this docker-compose.yml configuration file for TeamCity - server and agent.

version: "3.5"
services:
  server:
    image: jetbrains/teamcity-server:latest
    container_name: teamcity_server
    networks:
      - teamcity_network
    ports:
      - "8111:8111"
    extra_hosts:
      - "host.docker.internal:host-gateway"
    volumes:
      - datadir:/data/teamcity_server/datadir
      - logs:/opt/teamcity/logs
    environment:
      TEAMCITY_SERVER_MEM_OPTS: -Xmx1024m
  agent:
    image: jetbrains/teamcity-agent:latest
    container_name: teamcity_agent
    volumes:
      - agent_conf:/data/teamcity_agent/conf
    environment:
      - SERVER_URL=http://example.com:8111
networks:
  teamcity_network:
volumes:
  datadir:
  logs:
  agent_conf: 

TeamCity server and agent start correctly, I can login, create projects, connect to Git repository etc.

But my Java application needs Java 17, and TeamCity docker images provide Java 11. I tried to do upgrade, and logged in into docker Ubuntu docker exec -it <mycontainerId> bash but I am user and I have no system privileges to update Java in the container.

Question: How can I install Java 17 into container and replace Java 11 to Java 17? Or is there configuration option for docker-compose.yml to install Java 17 instead of 11?

1 comment
Comment actions Permalink

Hi,

It is not possible to replace the provided Java 11 with Java 17, as the Build Agent still requires Java 11. However, you can certainly customize the Docker image to have both Java 11 and 17. There are several ways to configure which Java the Build Agent will run on, please refer to Path to Java on Agent Machine for details on how to configure the Build Agent Java. 

With Java 17 installed on the Build Agent, you'll be able to use Java 17 in your builds, even though the Build Agent is running on Java 11. 

You can customize the image via the usual Docker procedure ( from the official Docker Hub page ):

  1. Run the image
docker run -e SERVER_URL="<url to TeamCity server>"  \ 
    -v <path to agent config folder>:/data/teamcity_agent/conf  \
    --name="my-customized-agent"  \
    jetbrains/teamcity-minimal-agent  \
  1. Enter the container
docker exec -it my-customized-agent bash
  1. Change whatever you need 

  2. Exit and create a new image from the container:

docker commit my-customized-agent <the registry where you what to store the image>
1

Please sign in to leave a comment.