Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

696
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda