Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

693
Views
Add Java to an NGINX Docker or add NGINX to a Java Docker on Alpine?

I need to build a Docker container (feeling as a N00b about it) that runs a Java application fronted by an nginx Web server. For reasons not subject to discussion I need to put them into one container.

I'd like to use Alpine for that. I found both images that contain Alpine with an installed nginx and Alpine with an installed JDK. I need to combine both.

What's my best course of action? Start with the nginx container and add a jdk or start with the jdk containing container and add nginx?

Or is there an option to combine 2 images (and would that be a good idea).

Insights are appreciated.

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

For creating a combined image, you could follow either of the suggested paths:

  • Creating a merged Dockerfile with the setup steps for both images, and building your own custom image.
  • Creating a Dockerfile pulling from image 1 (the more "complex" one), and adding the commands needed for image 2.

The second approach is preferred, since you start off a known-good image, not having to start from scrach. Plus, you may need only minimal changes. For this to work, both images should share a common base image, such as alpine for example.

Examining both Nginx and Java OpenJDK Dockerfiles, you could see that Nginx Dockerfile is fairly more complex, with many prerequisite packages and setup steps, so it would make a better fit for the base image. My suggestion is, start from the Nginx base image, and add Java on top.

If you're happy with the versions of JDK available in Alpile repositories, your combined Dockerfile may be as simple as:

FROM nginx:alpine

RUN apk add openjdk17

If you need a specific Java version, which isn't available in Alpine repositories, it's usually a matter of downloading the zipped Alpine Java distribution and unpacking it and setting JAVA_HOME accordingly. For example, see the OpenJDK 13 Alpine Dockerfile.

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!