title: How to run a Java webapp and Nginx in the same Docker container?
body: <p>I need to run a Java webapp and Nginx in the same Docker launch.</p>
  <p>My first attempt was this <code>Dockerfile</code>:</p>
  <pre><code>FROM openjdk:17-alpine
  ...
  COPY ./app_boot.sh app_boot.sh 
  ENTRYPOINT [&quot;sh&quot;, &quot;app_boot.sh&quot;]    
  FROM nginx:latest
  COPY devops/nginx_proxy.conf /etc/nginx/conf.d/default.conf
  EXPOSE 8080
  </code></pre>
  <p>This doesn't work, as the 2nd <code>FROM</code> overwrites the first one.</p>
  <p>My second attempt is to split up into two Dockerfiles and using this <code>docker-compose.yml</code>:</p>
  <pre><code>version: &quot;3&quot;
  services:
    web:
      build: .
      ports:
        - &quot;80:80&quot;
      links:
        - nginx
    nginx:
      build: devops/nginx
      ports:
        - &quot;8080:8080&quot;
  </code></pre>
  <p>But the problem now is slightly different... nginx returns error 502  and the logs show <code>upstream server temporarily disabled while connecting to upstream</code></p>