Why do I get "curl: not found" inside my node:alpine Docker container?

Viewed 13816

My api-server Dockerfile is following

FROM node:alpine

WORKDIR /src
COPY . .

RUN rm -rf /src/node_modules
RUN rm -rf /src/package-lock.json

RUN yarn install

CMD yarn start:dev

After docker-compose up -d

I tried

$ docker exec -it api-server sh
/src # curl 'http://localhost:3000/'
sh: curl: not found

Why is the command curl not found?

My host is Mac OS X.

1 Answers

node:alpine image doesn't come with curl. You need to add the installation instruction to your Dockerfile.

RUN apk --no-cache add curl

Full example from your Dockerfile would be:

FROM node:alpine

WORKDIR /src
COPY . .

RUN rm -rf /src/node_modules
RUN rm -rf /src/package-lock.json

RUN apk --no-cache add curl

RUN yarn install

CMD yarn start:dev
Related