Semen Shekhovtsov
Semen Shekhovtsov

Reputation: 882

Docker container (aspnet:5.0-alpine3.13) unable to download a file using curl

When I do following command using docker run the file downloads fine:

$ docker run mcr.microsoft.com/dotnet/aspnet:5.0-alpine3.13 apk add curl \
&& echo "start" \
&& curl -L --output file-example_PDF_1MB.pdf https://file-examples-com.github.io/uploads/2017/10/file-example_PDF_1MB.pdf && echo "done"

The file downloads fine, however when I try to download it in the container by the following Dockerfile:

FROM mcr.microsoft.com/dotnet/aspnet:5.0-alpine3.13 AS runtime
    
RUN apk add curl \
&& curl -L --output file-example_PDF_1MB.pdf https://file-examples-com.github.io/uploads/2017/10/file-example_PDF_1MB.pdf

The curl command fails with the following error message:

docker build -t testsem .
    
curl: (6) Could not resolve host: file-examples-com.github.io

The linux docker image is used (aspnet:5.0-alpine3.13) host OS is Windows 10 Pro.

I've tried to disable firewall on the host machine - no difference, same error message.

Upvotes: 2

Views: 715

Answers (1)

Antonio Petricca
Antonio Petricca

Reputation: 11026

A solution that worked for me was to add custom DNSs to docker configuration file /etc/docker/daemon.json like follow:

{
    "dns": [
        "1.1.1.1",
        "8.8.8.8"
     ]
}

I hope it may help you.

Regards.

Upvotes: 2

Related Questions