Thursday 29 July 2021

Starting Docker Images with PKI certificates

Before starting this post, Make Sure you copy the certificate to the location where you have the docker file. Edit the following docker file according to your requirement. My Requirement was to copy the jar and start in docker.


Below is my DockerFile


FROM java:8

EXPOSE 8084

ADD ./target/my.jar my_docker.jar

USER root

COPY my.cer $JAVA_HOME/jre/lib/security

RUN \

    cd $JAVA_HOME/jre/lib/security \

    && keytool -keystore cacerts -storepass changeit -noprompt -trustcacerts -importcert -alias ldapcert -file my.cer

ENTRYPOINT ["java","-jar","my.jar"]


Once you copy the certificate and import it using the key tool it will import successfully.


After this build it and run using the port.


Building the Docker image


docker build -t  cert-sample .


Running the Docker image


docker run -d -p 8084:8084 cert-sample


Happy Learning!!!!

1 comment:
Write comments