PatPanda
PatPanda

Reputation: 5000

Dockerfile - Image FROM two different images?

Small question regarding Dockerfile please.

Currently, I have a Dockerfile starting with the base image openjdk.

FROM openjdk:7
FROM curl:7.74.0
COPY . /usr/src/myapp
WORKDIR /usr/src/myapp
RUN javac Main.java
CMD ["java", "Main"]

The curl version inside this opened image is too old 7.29, and I would like to use the curl from the official image: https://hub.docker.com/r/curlimages/curl

Meaning, I would like to stick with the current openjdk I am using.

Just adding to it the latest version of the curl image.

My first attempt was to just add one more "FROM" like for the official curl image, but resulted in an error (I believe this is not even the right direction, what I added in the second like)

How to have in my one Dockerfile, the two (existing openjdk + latest version of curl) please?

Thank you

Upvotes: 2

Views: 374

Answers (1)

PatPanda
PatPanda

Reputation: 5000

This needs to be done through the multi stage Docker, as mentioned in the comments, worked for me.

Upvotes: 1

Related Questions