# Elm make fails inside alpine docker container

**URL:** <https://discourse.elm-lang.org/t/elm-make-fails-inside-alpine-docker-container/4958>\
**Category:** Learn\
**Created:** [January 9, 2020, 9:14am UTC](https://discourse.elm-lang.org/t/elm-make-fails-inside-alpine-docker-container/4958 "2020-01-09T09:14:06Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jwan](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.elm-lang.org/jwan/32/2849_2.png) [@Jwan](https://discourse.elm-lang.org/u/Jwan)\
**Post date:** [January 9, 2020, 9:14am UTC](https://discourse.elm-lang.org/t/elm-make-fails-inside-alpine-docker-container/4958/1 "2020-01-09T09:14:06Z")

</div>

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:

 ![image](https://canada1.discourse-cdn.com/flex035/uploads/elm_lang/original/2X/5/5e0af76f7e8a0dd0703e81d3eb1069a4815328d3.png)

And here is my [Dockerfile](https://github.com/JwanKhalaf/Bejebeje.Elm/blob/feature/dockerise/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.

---

<div class="post-metadata">

**Author:** ![dmy](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.elm-lang.org/dmy/32/702_2.png) [@dmy](https://discourse.elm-lang.org/u/dmy)\
**Post date:** [January 9, 2020, 9:36am UTC](https://discourse.elm-lang.org/t/elm-make-fails-inside-alpine-docker-container/4958/2 "2020-01-09T09:36:52Z")

</div>

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](http://package.elm-lang.org) resolution always works correctly in UDP:

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

```

then inside the container:

```bash
apk update
apk add bind-tools

```

then

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

```

You should get:

```auto
package.elm-lang.org.	14116	IN	A	45.55.106.189

```

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:

```bash
RUN echo "nameserver 8.8.8.8" > /etc/resolv.conf

```

Then try to build again.

---

<div class="post-metadata">

**Author:** ![allanderek](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.elm-lang.org/allanderek/32/1360_2.png) [@allanderek](https://discourse.elm-lang.org/u/allanderek)\
**Post date:** [January 9, 2020, 9:40am UTC](https://discourse.elm-lang.org/t/elm-make-fails-inside-alpine-docker-container/4958/3 "2020-01-09T09:40:48Z")

</div>

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

> <https://github.com/elm-lang/elm-package/issues/115>
>
> When attempting to run elm package install for the first time on a project I received the following error
> Error: failed with...

---

<div class="post-metadata">

**Author:** ![dmy](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.elm-lang.org/dmy/32/702_2.png) [@dmy](https://discourse.elm-lang.org/u/dmy)\
**Post date:** [January 9, 2020, 9:52am UTC](https://discourse.elm-lang.org/t/elm-make-fails-inside-alpine-docker-container/4958/4 "2020-01-09T09:52:23Z")

</div>

@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.

---

<div class="post-metadata">

**Author:** ![dmy](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.elm-lang.org/dmy/32/702_2.png) [@dmy](https://discourse.elm-lang.org/u/dmy)\
**Post date:** [January 9, 2020, 10:22am UTC](https://discourse.elm-lang.org/t/elm-make-fails-inside-alpine-docker-container/4958/5 "2020-01-09T10:22:03Z")

</div>

Note that your full build works fine on my system.

I did:

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

```

and got:

```auto
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 (140.82.118.3:443)
Connecting to github-production-release-asset-2e65be.s3.amazonaws.com (52.217.12.92:443)
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 (45.55.106.189): 56 data bytes
64 bytes from 45.55.106.189: seq=0 ttl=51 time=94.373 ms
64 bytes from 45.55.106.189: seq=1 ttl=51 time=92.638 ms
64 bytes from 45.55.106.189: seq=2 ttl=51 time=93.114 ms
64 bytes from 45.55.106.189: seq=3 ttl=51 time=90.074 ms
64 bytes from 45.55.106.189: 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

```

---

<div class="post-metadata">

**Author:** ![Jwan](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.elm-lang.org/jwan/32/2849_2.png) [@Jwan](https://discourse.elm-lang.org/u/Jwan)\
**Post date:** [January 9, 2020, 10:28am UTC](https://discourse.elm-lang.org/t/elm-make-fails-inside-alpine-docker-container/4958/6 "2020-01-09T10:28:12Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Jwan](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.elm-lang.org/jwan/32/2849_2.png) [@Jwan](https://discourse.elm-lang.org/u/Jwan)\
**Post date:** [January 9, 2020, 6:55pm UTC](https://discourse.elm-lang.org/t/elm-make-fails-inside-alpine-docker-container/4958/7 "2020-01-09T18:55:16Z")

</div>

@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.

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

```

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

```auto
[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
fetch:

    https://package.elm-lang.org/packages/elm/browser/1.0.2/endpoint.json

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:

```auto
[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? ☹

---

<div class="post-metadata">

**Author:** ![dmy](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.elm-lang.org/dmy/32/702_2.png) [@dmy](https://discourse.elm-lang.org/u/dmy)\
**Post date:** [January 9, 2020, 7:21pm UTC](https://discourse.elm-lang.org/t/elm-make-fails-inside-alpine-docker-container/4958/8 "2020-01-09T19:21:40Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Jwan](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.elm-lang.org/jwan/32/2849_2.png) [@Jwan](https://discourse.elm-lang.org/u/Jwan)\
**Post date:** [January 9, 2020, 7:28pm UTC](https://discourse.elm-lang.org/t/elm-make-fails-inside-alpine-docker-container/4958/9 "2020-01-09T19:28:48Z")

</div>

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?

```auto
/run/systemd/resolve/stub-resolv.conf

```

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

---

<div class="post-metadata">

**Author:** ![Jwan](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.elm-lang.org/jwan/32/2849_2.png) [@Jwan](https://discourse.elm-lang.org/u/Jwan)\
**Post date:** [January 10, 2020, 9:28am UTC](https://discourse.elm-lang.org/t/elm-make-fails-inside-alpine-docker-container/4958/10 "2020-01-10T09:28:58Z")

</div>

**UPDATE**

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](https://wiki.manjaro.org/index.php?title=Set_DNS_or_Nameservers) to be `8.8.8.8` (that’s Google’s DNS server) and now `elm make` works on my machine **and** inside a docker container.

```auto
[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:

```auto
Address: 8.8.8.8#53

```

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 ❤

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex035/uploads/elm_lang/original/1X/50a05e53677a2c3b47776d7abd0f113eb50193a1.png) [@system](https://discourse.elm-lang.org/u/system)\
**Post date:** [January 20, 2020, 9:36am UTC](https://discourse.elm-lang.org/t/elm-make-fails-inside-alpine-docker-container/4958/11 "2020-01-20T09:36:56Z")

</div>

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