2

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

PatPanda
  • 3,644
  • 9
  • 58
  • 154
  • Please provide all information necessary to reproduce the issue, like your Dockerfile with the two `FROM` statements. – Daniel W. Jan 23 '21 at 14:04
  • You don;t need to add another docker image of curl, instead just install curl package in your openjdk image. It would be great if you can share your dockerfile contents. – mchawre Jan 23 '21 at 14:07
  • [Docker: Combine multiple images](https://stackoverflow.com/questions/27214757/docker-combine-multiple-images) discusses the question you ask in the title (short answer: you can't). In the context of a Java application, can you use the native Java HTTP libraries instead of needing an external program? – David Maze Jan 23 '21 at 14:12
  • Question updated with the content of the Dockerfile – PatPanda Jan 23 '21 at 14:32
  • I just want something newer than the default curl already present – PatPanda Jan 23 '21 at 14:32
  • [Update Dependencies in Jre/Docker Image](https://stackoverflow.com/a/51209115/1948292) [Composing vs Multi Staging](https://stackoverflow.com/questions/44833242/docker-compose-vs-multi-stage-build) and [Docker Multi Stage Builds](https://docs.docker.com/develop/develop-images/multistage-build/) might be helpful! – Daniel W. Jan 23 '21 at 19:04

1 Answers1

1

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

PatPanda
  • 3,644
  • 9
  • 58
  • 154