The use case is such that I need both JDK and Mongo images in a single container, the java process starts up the Mongo daemon process.
CodePudding user response:
You are not needed to use two base images. just use one of the base image jdk/mongo and then using binaries install mongo/jdk on top of the chosen base image.
CodePudding user response:
Here's the minimum Dockerfile that bake JRE 11 to the mongo image.
FROM mongo:latest
# Replace the version if desired
RUN apt-get update -y && apt-get install openjdk-11-jre-headless -y
# Install your app and stuffs here...
# Override for your own command
CMD ["java","-version"]
Build the image docker build -t mongodb-java .
Test the image docker run -t --rm mongodb-java
will output the JRE version.
Test the image docker run -t --rm mongodb-java mongo --version
will output the MongoDB version.
You can then follow Kaniko steps to build the image.