Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

694
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda