Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 851
Heisenberg Avatar asked Oct 11 '20 04:10

Heisenberg


People also ask

Is curl available in Alpine?

Curl is URL retrieval (download/upload) command-line utility and library. It is free software for Alpine Linux. This page explains how to search and install curl on Alpine Linux using the apk command.

Does Docker Alpine have curl?

Like it says, it's a docker image built on alpine with curl installed. Size 5.93 MB.


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
like image 56
Nathan Avatar answered Oct 13 '22 18:10

Nathan