title: What is exec in Dockerfile ENTRYPOINT and why is a process started twice without it?
body: <p>I have the following Dockerfile</p>
  
  <pre><code>FROM openjdk:8-jre-slim
  
  # Copy the files
  COPY target/app-1.0.jar /home/app.jar
  COPY conf/log4j.xml /home/conf/
  COPY conf/bootstrap.properties /home/conf/
  
  WORKDIR /home
  
  
  ENV APP_OPTS="-Dversion=1 -Dkey=value"
  
  # Default log4j config - logs INFO
  ARG LOG4J_CONFIG_FILE=conf/log4j.xml
  ENV LOG4J_CONFIG_FILE=$LOG4J_CONFIG_FILE
  
  ENV BOOTSTRAP_CONFIG=conf/bootstrap.properties
  
  ENTRYPOINT java $APP_OPTS -DBOOTSTRAP_CONFIG=$BOOTSTRAP_CONFIG -jar app.jar
  </code></pre>
  
  <p>and I see from <code>docker top</code> command:</p>
  
  <pre><code>UID   PID   PPID  C  STIME  TIME     CMD
  root  7756  7735  0  19:20  00:00:00 /bin/sh -c java $APP_OPTS -DBOOTSTRAP_CONFIG=$BOOTSTRAP_CONFIG -jar app.jar
  root  7783  7756  41 19:20  00:00:05 java -Dversion=1 -Dkey=value -DBOOTSTRAP_CONFIG=conf/bootstrap.properties -jar app.jar
  </code></pre>
  
  <p>what when I add <code>exec</code> before the ENTRYPOINT, I see only the last process.</p>
  
  <p><code>ENTRYPOINT exec java $APP_OPTS -DBOOTSTRAP_CONFIG=$BOOTSTRAP_CONFIG -jar app.jar</code></p>
  
  <p>Why is this so and what is the <em>magic</em> that exec does?</p>