Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Haskell - hostname resolution inside Alpine Docker image does not work

The Issue

I am trying to create docker image with the Haskell application inside. however, the domain name resolution of hostnames of other containers in the network in my application inside docker container fails (but I am able to wget / ping other containers and their hostnames are correctly resolved).

To find the root cause I tried to resolve manually hostnames (using Network.DNS package) and use only IP addresses in servant-client. However this yields just cryptic error message:

Network.BSD.getProtocolByName: does not exist (no such protocol name: udp)

I think I am missing some packages inside my docker image. I've tried installing libc6-compat but without success (libc6 from Debian was used to compile Haskell application). Moreover /etc/protocols contains correct entries. What else is missing inside a docker image?

Docker images

The docker image I am using to run the application is alpine:3.6 - Whole dockerfile, there's not much in it. This is different image than used to build the application (It is ~20x smaller).

The docker image I am using to build the haskell app is based on debian:stretch. Dockerfile.

Whole source code with the build instructions is available here (Angular part can be skipped):

https://github.com/carbolymer/blockchain/tree/0b041875f71b2a09dc8568ee7b0cc22460fd5624

like image 827
carbolymer Avatar asked Nov 12 '17 00:11

carbolymer


1 Answers

It sounds like you are missing some linked dependencies for your Haskell code to run.

Alpine uses musl libc to cutdown on size which means most standard linked binaries won't run from the standard distros as they use GNU libc. Either compile your app as normal in an alpine image or create a statically linked binary to run in any Linux distro/container.

The base Debian layer is shared between any image that uses it, so you're probably not saving as much space as you think in any case. If it's going to be easier to use the Debian image, then use that.

like image 139
Matt Avatar answered Sep 30 '22 10:09

Matt