skip to Main Content

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.

2

Answers


  1. 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.

    Login or Signup to reply.
  2. 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.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search