For using already configured java based containers like jenkins, sonarqube or nexus (e. g. if you run your own build server) I find it more convenient to mount a suitable cacerts-file into these containers with a parameter for docker run .
I use the cacerts file from openjdk as base:
- extracting
cacertsfrom openjdk image using a temporary container:
docker pull openjdk:latest
docker run --rm --entrypoint cat openjdk:latest /etc/ssl/certs/java/cacerts > cacerts
- adding certificate to the extracted
cacertsusing a temporary container started from the same folder which also containsldap.cer:
docker run --rm -v `pwd`:/tmp/certs openjdk:latest bash -c 'cd /tmp/certs && keytool -keystore cacerts -storepass changeit -noprompt -trustcacerts -importcert -alias buenting-root -file ldap.cer'
- run your target docker container(s) mounting the extracted
cacertswith a run-parameter, e. g. forsonarqube:
docker run ... -v /path/to/your/prepared/cacerts:/etc/ssl/certs/java/cacerts:ro ... sonarqube:lts
If there is a new version of openjdk you can update the cacerts-file on the host with commands from 1. and 2.
For updating the target image (e. g. sonarqube) you do not need to create your own image using Dockerfile and docker build.