Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

1.1K
Views
sh: curl: not found even install curl inside k8s pod

It might be simple question but I could not find the proper solution.

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.

$ 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

Tried with bash

$ kubectl exec -ti cronjob-dev-597cc575f-6lfdc -n hub-dev bash
 mand in container: failed to exec in container: failed to start exec "8019bd0d92aef2b09923de78753eeb0c8b60a78619543e4cd27069128a30da92": OCI runtime exec failed: exec failed: container_linux.go:349: starting container process caused "exec: \"bash\": executable file not found in $PATH": unknown

Dockerfile

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 -> did not work
RUN apk update && apk add curl curl-dev bash -> 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 [ "npm", "run", "start:docker" ]
over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Your Dockerfile consists of multiple stages, which is also called multi-stage build.

Each FROM statement is a new stage and new image. In your case you have 2 stages:

  • builder where you build you app and install curl
  • second stage which copies /usr/src/app from builder stage

In this case second FROM node:12-alpine statement will contain only basic alpine packages, node tools and /usr/src/app which you have copied from the first stage.

If you want to have curl in your final image you need to install curl in second stage (after second FROM node:12-alpine):

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 && apk add curl

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

# run the application
EXPOSE 50005 9183

CMD [ "npm", "run", "start:docker" ]

As it was mentioned in comments you can test it by running docker container directly - no need to run pod in k8s cluster:

docker build -t image . && docker run -it image sh -c 'which curl'

It is common to use multi-stage build for applications implemented in compiled programming languages.

  1. 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.
  2. 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.
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!