RUN curl fails in dockerfile but works from command line RUN curl fails in dockerfile but works from command line curl curl

RUN curl fails in dockerfile but works from command line


You can see the curl error message when running the last commited image from the build with curl command:

docker run -it --rm lastCommitedImageHash curl -k -o app.jar -kfSL https://mynexus:9006/repository/legacy/1.0.2/app.jar

I had the same problem last week - curl worked directly from host but not when ran during build from Dockerfile.

Restart of Docker daemon helped to me.

I haven't found what was the reason of that state. It was on the machine which is also as a Kubernetes master and I did Kubernetes cluster upgrade last week and probably this was the source of that problem.

Another cause of that problem in your case can be if you have mynexus hostname defined only in the /etc/hosts file on the host machine and then it is unknown for the running container during the build.