<p>It might be simple question but I could not find the proper solution.</p>
<p>I have a Docker image as below.. The things that I would like to do simply run curl command inside kubernetes pod but I received an error as below.. I could not able to exec via bash also.</p>
<pre><code>$ kubectl exec -ti hub-cronjob-dev-597cc575f-6lfdc -n hub-dev sh
Defaulting container name to hub-cronjob.
Use 'kubectl describe pod/hub-cronjob-dev-597cc575f-6lfdc -n hub-dev' to see all of the containers in this pod.
/usr/src/app $ curl
sh: curl: not found
</code></pre>
<p>Tried with bash</p>
<pre><code>$ kubectl exec -ti cronjob-dev-597cc575f-6lfdc -n hub-dev bash
 mand in container: failed to exec in container: failed to start exec &quot;8019bd0d92aef2b09923de78753eeb0c8b60a78619543e4cd27069128a30da92&quot;: OCI runtime exec failed: exec failed: container_linux.go:349: starting container process caused &quot;exec: \&quot;bash\&quot;: executable file not found in $PATH&quot;: unknown
</code></pre>
<p>Dockerfile</p>
<pre><code>FROM node:12-alpine AS builder

# Variables from outside
ARG NODE_ENVIRONMENT=development
ENV NODE_ENV=$NODE_ENVIRONMENT

# Create app directory
WORKDIR /usr/src/app

#Install curl
RUN apk --no-cache add curl -&gt; did not work
RUN apk update &amp;&amp; apk add curl curl-dev bash -&gt; did not work

# Install app dependencies
COPY package*.json ./
RUN npm install

# Bundle app source
COPY . .

# Build Stage 2
# Take the build from the previous stage
FROM node:12-alpine

WORKDIR /usr/src/app
COPY --from=builder /usr/src/app /usr/src/app

# run the application
EXPOSE 50005 9183

CMD [ &quot;npm&quot;, &quot;run&quot;, &quot;start:docker&quot; ]
</code></pre>

<p>Your Dockerfile consists of multiple stages, which is also called <a href="https://docs.docker.com/develop/develop-images/multistage-build/" rel="noreferrer">multi-stage build</a>.</p>
<p>Each <code>FROM</code> statement is a new stage and new image. In your case you have 2 stages:</p>
<ul>
<li><code>builder</code> where you build you app and install curl</li>
<li><code>second stage</code> which copies /usr/src/app from <code>builder</code> stage</li>
</ul>
<p>In this case second <code>FROM node:12-alpine</code> statement will contain only basic alpine packages, node tools and /usr/src/app which you have copied from the first stage.</p>
<p>If you want to have curl in your final image you need to install <code>curl</code> in second stage (after second <code>FROM node:12-alpine</code>):</p>
<pre><code>FROM node:12-alpine AS builder

# Variables from outside
ARG NODE_ENVIRONMENT=development
ENV NODE_ENV=$NODE_ENVIRONMENT

# Create app directory
WORKDIR /usr/src/app

# Do not install 

# Install app dependencies
COPY package*.json ./
RUN npm install

# Bundle app source
COPY . .

# Build Stage 2
# Take the build from the previous stage
FROM node:12-alpine

#Install curl
RUN apk update &amp;&amp; apk add curl

WORKDIR /usr/src/app
COPY --from=builder /usr/src/app /usr/src/app

# run the application
EXPOSE 50005 9183

CMD [ &quot;npm&quot;, &quot;run&quot;, &quot;start:docker&quot; ]
</code></pre>
<p>As it was mentioned in comments you can test it by running docker container directly - no need to run pod in k8s cluster:</p>
<pre class="lang-sh prettyprint-override"><code>docker build -t image . &amp;&amp; docker run -it image sh -c 'which curl'
</code></pre>
<p>It is common to use multi-stage build for applications implemented in compiled programming languages.</p>
<ol>
<li>In the first stage you install all necessary dev tools and compilers and then compile sources into a binary file. Since you don't need and probably don't want sources and developer's tools in a production image you should create a new stage.</li>
<li>In the second stage you copy compiled binary file and run it as CMD or ENTRYPOINT. This way your image contains only executable code, which makes them smaller.</li>
</ol>
