0

This is a linked question to my previous question RUN cmd and execute curl command in VB.NET.

I have a vb.net very small application that makes a api call and prints the response.

Module Module1

    Sub Main()
 Dim curlApplicationPath = IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.System), "curl.exe")
 Dim arguments = $"/k {curlApplicationPath} --location --request GET http://ip:port/"
        
     Process.Start("cmd.exe", arguments)

    End Sub 
End Module

I want now to run this application in docker (for windows). This is what I wrote in dockerfile.

From mcr.microsoft.com/windows:1903
From curlimages/curl:latest
From mcr.microsoft.com/dotnet/framework/runtime:4.6.2
WORKDIR /app
COPY bin/Release .
ENTRYPOINT ["CurlCall.exe"]

and build the image by running the following command

docker build -t curlcall .

Upon running the following command

docker run --rm -it curlcall

My expected response was hello-world, which I get when I am running my vb.net application outside of docker. But I get no response at all. Then I logged into the interactive session of the image by

docker run -it --entrypoint=cmd.exe curlcall 

and tried to run curl google.com and got the response that

'curl' is not recognized as an internal or external command,
operable program or batch file.

Then I copied the curl executeable manually in the docker image and CD into

C:\test\curl-7.79.1-win64-mingw\bin>curl

and ran this command and it works as expected.

curl --location --request GET http://ip:port/

I think this is the main problem that Curl is not configured during the build process, and I search around but couldn't find a way to configure CURL via dockerfile.

I hope I explained the question well. Could anyone please help me figure out the situation?

Thanks a lot in advance.

SAIP
  • 99
  • 7
  • There's no way to combine images; each `FROM` line starts a new image from the named base image. So you have a plain .NET Runtime image and you need to install Curl into it in some other way. – David Maze Sep 28 '21 at 14:57
  • (Not a .NET expert at all, but is there a C#-native HTTP client you can use, instead of shelling out to `curl`?) – David Maze Sep 28 '21 at 14:58
  • Okay. I will take into account the first commend, I didn't know that we can't combine the images. And secondly I have many curl commands and translating them into httprequests would be a lot of work so the idea is to simply run curl commands. – SAIP Sep 28 '21 at 15:11

0 Answers0