Elm make fails inside alpine docker container

Hello everyone

For the past 3 weeks I’ve been stuck trying to get elm make to work inside a docker container. I get the following error:

And here is my Dockerfile (code is open source)

Is there anyone here who uses Linux? Any ideas on why this might be failing on my machine? I’m running Manjaro Linux and it is a new install, about 6 weeks.

It looks like a DNS issue.

elm binary will use the DNS nameservers from /etc/resolv.conf to resolve domain names, and IIRC TCP queries are not supported. So maybe first check that this works fine:

You could open a shell inside your container, install dig and test that package.elm-lang.org resolution always works correctly in UDP:

docker run -it --rm alpine:3.11.2 /bin/ash

then inside the container:

apk update
apk add bind-tools


# Replace by the nameserver defined in your /etc/resolv.conf
dig @ +noall +answer +notcp +retry=0 package.elm-lang.org

You should get:

package.elm-lang.org.	14116	IN	A

Run it several times to check that it is reliable (maybe in a loop).

Also to be sure it’s not linked to your local DNS resolution, try to add the following command in your Dockerfile before the elm make one:

RUN echo "nameserver" > /etc/resolv.conf

Then try to build again.

Unfortunately, as far I as understand it, this is a problem with the Haskell http-client library.

@allanderek This issue is quite old without much activity, it seems to be sporadic, much folks in it had their issue solved, and information is very light.

I just cloned elm-spa-example in alpine 3.11.2 container then run elm make src/Main.elm without issues, so there is more to it than just a problem with http-client, something linked to the environment.

Note that your full build works fine on my system.

I did:

git clone https://github.com/JwanKhalaf/Bejebeje.Elm.git
git checkout  feature/dockerise
docker build -t beje -f Dockerfile .

and got:

Sending build context to Docker daemon  193.5kB
Step 1/13 : FROM alpine:3.11.2 AS builder
 ---> cc0abc535e36
Step 2/13 : MAINTAINER Jwan Khalaf <jwan.khalaf@outlook.com>
 ---> Running in cb538e8c2fc6
Removing intermediate container cb538e8c2fc6
 ---> ab26baf3031b
Step 3/13 : RUN wget -O - 'https://github.com/elm/compiler/releases/download/0.19.1/binary-for-linux-64-bit.gz'     | gunzip -c >/usr/local/bin/elm
 ---> Running in 3d3f96f04f5e
Connecting to github.com (
Connecting to github-production-release-asset-2e65be.s3.amazonaws.com (
writing to stdout
-                      1% |                                |  101k  0:01:04 ETA
-                     29% |*********                       | 1936k  0:00:04 ETA
-                     89% |****************************    | 5952k  0:00:00 ETA
-                    100% |********************************| 6647k  0:00:00 ETA
written to stdout
Removing intermediate container 3d3f96f04f5e
 ---> cc0e70d1faa0
Step 4/13 : RUN chmod +x /usr/local/bin/elm
 ---> Running in ae38fd48cda0
Removing intermediate container ae38fd48cda0
 ---> 98a906c215a6
Step 5/13 : RUN apk update
 ---> Running in 5c6f32f2bcc2
fetch http://dl-cdn.alpinelinux.org/alpine/v3.11/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.11/community/x86_64/APKINDEX.tar.gz
v3.11.2-51-g7cf8ea7952 [http://dl-cdn.alpinelinux.org/alpine/v3.11/main]
v3.11.2-49-g34d72ac2bf [http://dl-cdn.alpinelinux.org/alpine/v3.11/community]
OK: 11261 distinct packages available
Removing intermediate container 5c6f32f2bcc2
 ---> e658f6d81e56
Step 6/13 : RUN apk add --update nodejs npm
 ---> Running in c9e9d0b7c7ee
(1/8) Installing ca-certificates (20191127-r0)
(2/8) Installing c-ares (1.15.0-r0)
(3/8) Installing libgcc (9.2.0-r3)
(4/8) Installing nghttp2-libs (1.40.0-r0)
(5/8) Installing libstdc++ (9.2.0-r3)
(6/8) Installing libuv (1.34.0-r0)
(7/8) Installing nodejs (12.14.0-r0)
(8/8) Installing npm (12.14.0-r0)
Executing busybox-1.31.1-r8.trigger
Executing ca-certificates-20191127-r0.trigger
OK: 64 MiB in 22 packages
Removing intermediate container c9e9d0b7c7ee
 ---> 0d0e8bd27e73
Step 7/13 : RUN apk add curl
 ---> Running in 6e18be8275fb
(1/2) Installing libcurl (7.67.0-r0)
(2/2) Installing curl (7.67.0-r0)
Executing busybox-1.31.1-r8.trigger
OK: 64 MiB in 24 packages
Removing intermediate container 6e18be8275fb
 ---> b0baa37ce6f1
Step 8/13 : RUN npm install uglify-js --global
 ---> Running in a61a2dc3a97f
/usr/bin/uglifyjs -> /usr/lib/node_modules/uglify-js/bin/uglifyjs
+ uglify-js@3.7.4
added 3 packages from 38 contributors in 4.054s
Removing intermediate container a61a2dc3a97f
 ---> c390065200fc
Step 9/13 : WORKDIR /app
 ---> Running in d3c42b571622
Removing intermediate container d3c42b571622
 ---> 998df5e14f5b
Step 10/13 : COPY . .
 ---> 2ca37c16fe82
Step 11/13 : RUN ping -c 5 package.elm-lang.org
 ---> Running in 93f56a8af22c
PING package.elm-lang.org ( 56 data bytes
64 bytes from seq=0 ttl=51 time=94.373 ms
64 bytes from seq=1 ttl=51 time=92.638 ms
64 bytes from seq=2 ttl=51 time=93.114 ms
64 bytes from seq=3 ttl=51 time=90.074 ms
64 bytes from seq=4 ttl=51 time=85.909 ms

--- package.elm-lang.org ping statistics ---
5 packets transmitted, 5 packets received, 0% packet loss
round-trip min/avg/max = 85.909/91.221/94.373 ms
Removing intermediate container 93f56a8af22c
 ---> b184d5eeebba
Step 12/13 : RUN curl https://package.elm-lang.org/packages/elm/file/1.0.5/endpoint.json
 ---> Running in 84a2b0e85f82
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   102  100   102    0     0    189      0 --:--:-- --:--:-- --:--:--   189
{"url":"https://github.com/elm/file/zipball/1.0.5/","hash":"9be249cec687caeb7cbdd85027b5e38625a9789e"}Removing intermediate container 84a2b0e85f82
 ---> c3746c13caa1
Step 13/13 : RUN elm make src/app/Main.elm --optimize --output=elm.js
 ---> Running in d8925a01e83b
Starting downloads...

  ● elm/time 1.0.0
  ● elm/virtual-dom 1.0.2
  ● elm/json 1.1.3
  ● elm/url 1.0.0
  ● elm/http 2.0.0
  ● elm/file 1.0.5
  ● elm/html 1.0.0
  ● elm/bytes 1.0.8
  ● elm/browser 1.0.2
  ● elm/core 1.0.4

Dependencies ready!           
Success! Compiled 2 modules.

    Main ───> elm.js

Removing intermediate container d8925a01e83b
 ---> 04c58a941cd2
Successfully built 04c58a941cd2
Successfully tagged beje:latest

Thanks @dmy, I’ll try your suggestion when I get home this evening. I’ll post an update then. Thank you. This has been bugging for 3 weeks now, so frustrating! Your help is very much appreciated. I’ll be back in the evening.

1 Like

@dmy here are the results:

On Host Machine / My Own Desktop (i.e. not docker)

I first deleted everything inside ~/.elm/0.19.1/packages/* and removed the elm-stuff folder from my project root.

[jwan@jwan-pc ~]$ cat /etc/resolv.conf
# Generated by NetworkManager
[jwan@jwan-pc ~]$ dig @ +noall +answer +notcp +retry=0 package.elm-lang.org
package.elm-lang.org.   14400   IN      A
[jwan@jwan-pc ~]$ dig @ +noall +answer +notcp +retry=0 package.elm-lang.org
package.elm-lang.org.   14377   IN      A
[jwan@jwan-pc ~]$ dig @ +noall +answer +notcp +retry=0 package.elm-lang.org
package.elm-lang.org.   14375   IN      A
[jwan@jwan-pc ~]$ dig @ +noall +answer +notcp +retry=0 package.elm-lang.org
package.elm-lang.org.   14372   IN      A
[jwan@jwan-pc ~]$ dig @ +noall +answer +notcp +retry=0 package.elm-lang.org
package.elm-lang.org.   14371   IN      A
[jwan@jwan-pc ~]$ dig @ +noall +answer +notcp +retry=0 package.elm-lang.org
package.elm-lang.org.   14371   IN      A
[jwan@jwan-pc ~]$ 

I then ran elm make src/app/Main.elm --output=/dev/null and here is what I got:

[jwan@jwan-pc bejebeje.elm]$ elm make src/app/Main.elm --output=/dev/null
Starting downloads...

  ● elm/bytes 1.0.8
  ● elm/file 1.0.5
  ● elm/core 1.0.4
  ✗ elm/json 1.1.3
  ✗ elm/browser 1.0.2
  ✗ elm/http 2.0.0
  ✗ elm/time 1.0.0
  ✗ elm/virtual-dom 1.0.2
  ✗ elm/url 1.0.0
  ● elm/html 1.0.0

Dependency problem!           
-- PROBLEM DOWNLOADING PACKAGE -------------------------------------------------

I need to find the latest download link for elm/browser 1.0.2, so I tried to


But my HTTP library is giving me the following error message:

    ConnectionFailure Network.Socket.getAddrInfo (called with preferred socket type/protocol: AddrInfo {addrFlags = [AI_ADDRCONFIG], addrFamily = AF_UNSPEC, addrSocketType = Stream, addrProtocol = 0, addrAddress = <assumed to be undefined>, addrCanonName
 = <assumed to be undefined>}, host name: Just "package.elm-lang.org", service name: Just "443"): does not exist (Try again)

Are you somewhere with a slow internet connection? Or no internet? Does the link
I am trying to fetch work in your browser? Maybe the site is down? Does your
internet connection have a firewall that blocks certain domains? It is usually
something like that!

[jwan@jwan-pc bejebeje.elm]$ 

As you can see, it failed even on the host machine. Perhaps I should try to fix this before trying to get it working within docker?

Note: If I run a couple of more times, then eventually all download and it works:

[jwan@jwan-pc bejebeje.elm]$ elm make src/app/Main.elm --output=/dev/null
Starting downloads...

  ● elm/browser 1.0.2
  ● elm/virtual-dom 1.0.2

Dependencies ready!           
Success! Compiled 2 modules.
[jwan@jwan-pc bejebeje.elm]$ 

Any ideas? :frowning:

This is expected, because the Docker container uses the host DNS resolution.

So you can do the tests I proposed earlier, on the host or in the container, this should give the same results.

It seems your system DNS resolution (at least using UDP) has some reliability issues, you should check carefully your /etc/resvolv.conf,systemd-resolved configuration, and the DNS servers you use.

Do you use your ISP DNS servers?
Maybe try other ones like google or openDNS ones to check if it solves the issue.

I’m not sure what DNS server I’m using, I’ve never had to worry about this before. How can I check?

Also, do you have the following file?


I don’t have a resolve directory under /run/systemd/. I’m not sure if that is a problem.


So this wasn’t an Elm issue, but here’s what worked for me in case you’re in the same boat.

On my machine running Manjaro linux, I went and changed my DNS server to be (that’s Google’s DNS server) and now elm make works on my machine and inside a docker container.

[jwan@jwan-pc bejebeje.elm]$ elm make src/app/Main.elm --output=/dev/null
Starting downloads...
  ● elm/file 1.0.5
  ● elm/http 2.0.0
  ● elm/virtual-dom 1.0.2
  ● elm/bytes 1.0.8
  ● elm/url 1.0.0
  ● elm/html 1.0.0
  ● elm/core 1.0.4
  ● elm/json 1.1.3
  ● elm/time 1.0.0
  ● elm/browser 1.0.2
Dependencies ready!           
Success! Compiled 2 modules.

Run nslookup google.com and look out for this:


The bit before the # is your DNS server.

I will most likely use openDNS servers instead of Google’s, but at least it now works.

Many thanks @dmy for the help :heart:

1 Like

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.