Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

curl doesn't work during docker build

I am writing a Dockerfile based on wildfly image. I have isolated these lines where I am having some headache. The curl command doesn't work during build process. I have already uninstalled and installed Docker again but the error persists. My system is a Linux Mint. In addition I tried to build that same Dockerfile in a RHEL and it worked like a charm.

Here's the Dockerfile:

FROM jboss/wildfly

RUN cd $HOME \
    && curl -O "http://central.maven.org/maven2/mysql/mysql-connector-java/5.1.44/mysql-connector-java-5.1.44.jar"

Here's the error output:

Sending build context to Docker daemon   1.03MB
Step 1/6 : FROM jboss/wildfly
 ---> b695bdcce374
Step 2/6 : RUN cd $HOME     && curl -O "http://central.maven.org/maven2/mysql/mysql-connector-java/5.1.44/mysql-connector-java-5.1.44.jar"
 ---> Running in 4fdcef7dbda1
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:--  0:00:39 --:--:--     0
  curl: (6) Could not resolve host: central.maven.org; Unknown error
The command '/bin/sh -c cd $HOME     && curl -O "http://central.maven.org/maven2/mysql/mysql-connector-java/5.1.44/mysql-connector-java-5.1.44.jar"' returned a non-zero code: 6
like image 732
M. Goes Avatar asked Nov 07 '17 00:11

M. Goes


1 Answers

I could workaround the problem doing something like this:

docker build --add-host central.maven.org:151.101.56.209 .

but I'm not happy with that. I would like to say Docker to use my DNS instead of set fixed IP. It would be more elegant.

like image 120
M. Goes Avatar answered Oct 05 '22 17:10

M. Goes