Docker RUN vs CMD vs ENTRYPOINT
<p>In Docker build, the three instructions <code>RUN</code> , <code>CMD</code> and <code>ENTRYPOINT</code> look similar and all are instructions used in a Dockerfile to define various aspects of a Docker image. Sometimes it can easily cause confusions. Let’s discuss their differences in this article.</p>
<h1>RUN vs CMD vs ENTRYPOINT</h1>
<ul>
<li><code>RUN</code> executes commands and creates new image layers.</li>
<li><code>CMD</code> sets the command and its parameters to be executed by default after the container is started. However <code>CMD</code> can be replaced by <code>docker run</code> command line parameters.</li>
<li><code>ENTRYPOINT</code> configures the command to run when the container starts, similar to <code>CMD</code> from a functionality perspective.</li>
</ul>
<h1>Shell Format vs Exec Format</h1>
<p>We can specify the command to be run by RUN, CMD and ENTRYPOINT in two ways: <code>Shell format</code> and <code>Exec format</code>, which have subtle differences in usage.</p>
<h2>Shell Format</h2>
<p>Shell format has the following form:</p>
<p><a href="https://tonylixu.medium.com/docker-run-vs-cmd-vs-entrypoint-57f248b95889"><strong>Visit Now</strong></a></p>