How to install curl from Dockerfile

Viewed 115

I'm trying to install curl on my Docker container to use it in a health check, but I can' seem to get it to install by running commands in the Dockerfile. Here is my Dockerfile:

FROM mcr.microsoft.com/dotnet/sdk:6.0 AS base
RUN apt-get update \
 && apt-get install -y curl
WORKDIR /app
COPY /Project.MyProject .
RUN dotnet publish -o /publish
WORKDIR /publish
ENTRYPOINT ["sh", "-c", "dotnet Project.MyProject.dll \"${DB_CONNECTION}\""]

Then when I run any curl command from inside the container by first doing docker exec it then it tells me curl not found. If I run apt-get update && apt-get install -y curl when the container is up and running then curl installs just fine. How can I get curl to install by running commands in the Dockerfile? I would like to avoid having to install it manually after the container is up and running.

0 Answers
Related