jnemecz
jnemecz

Reputation: 3628

How to upgrade JDK in Docker compose 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?

Upvotes: 0

Views: 897

Answers (1)

Guss
Guss

Reputation: 32384

You shouldn't update the JDK version of the TeamCity server - you generally don't want to modify the server dependencies as that may cause instability.

What you are supposed to be doing (and the example compose file kind of shows it) is to use the agent container to run your build, or more correctly - build a new image - based on the agent image (i.e. uses FROM jetbrains/teamcity-agent:latest) - where you install whatever tools you need for your build.

The agent images are also locked to a user, but they install sudo so you should be able to use that to build an image with updated JDK. Another alternative is to build a completely new image for the agent by copying the open source TeamCity agent Docker file from their Github repository and updating it as needed.

Upvotes: 1

Related Questions