[erlang-questions] erlang in docker from scratch

Loïc Hoguin <>
Mon Mar 28 21:37:32 CEST 2016


On 03/28/2016 05:51 PM, Peter Morgan wrote:
>
>> On 27 Mar 2016, at 16:37, Loïc Hoguin <> wrote:
>>
>> On 03/27/2016 05:01 PM, Peter Morgan wrote:
>>> Much of the above is completely boilerplate, perhaps a erlang.mk “bootstrap-docker” makes sense? Or are people using other/better methods to package applications in Docker that I have missed?
>>
>> I am totally open to that.
>>
>> What would be great, would be to be able to build on top of the release handling. If the project uses Docker, then "make" should build the container and "make run" should run the container (instead of building the release and running it). Does that make sense?
>>
>> If we do that, then the only other important thing is the bootstrap-docker target.
>
>
> Awesome - I’ve forked. I have some changes, they need a bunch more testing - they’re not going to work on anything other than Linux at the moment. I’ll look at OSX, but that will mean getting a Linux ERTS from somewhere into the container somehow - probably “FROM erlang” - but that is enormous.
>
> I’ve added a docker plugin which is weaved it into the ‘rel’ target, with a ‘bootstrap-docker’ to bootstrap.mk - it probably could do with a “.dockerignore” in there too, and some help. The dynamic libraries probably should be copied using something like http://stackoverflow.com/questions/16929445/makefile-dynamic-rules-based-on-a-file - but I’ve struggled with that - everything being .PHONY seems wrong…

Don't be worried about details. Most important is having tests and that 
they pass. We can then improve things easily.

> The below works for me on Fedora:

Must be some issues, got:

strip $(file _rel/*/erts-*/bin/*|grep "not stripped"|awk '{print 
$1}'|cut -d: -f1) &>/dev/null
erlang.mk:6634: recipe for target 'docker-strip-erts-binaries' failed
make: [docker-strip-erts-binaries] Error 1 (ignored)

And:

$ make docker-run
  GEN    docker-rm
  GEN    docker-run
5af98425557abc276483dca047bb711fceb86e929a6cd022ca93d8344893ed6f
$ docker ps -a
CONTAINER ID        IMAGE                      COMMAND 
CREATED             STATUS                       PORTS               NAMES
5af98425557a        dockerdemo_release:0.0.1   "/bin/sh -c 'exec ${B" 
3 seconds ago       Exited (127) 3 seconds ago 
dockerdemo_release

> Also - should “-heart” be default in vm.args? Heart is kind of redundant with docker —restart=always and breaks the one-process-per-container rule (similar for epmd).

-heart makes sense for releases, although it really depends on how you 
run them. It's better to have it as a default and have people remove it 
knowingly I think.

-heart should on the other hand always be stripped when using Docker I 
guess. Not too sure what's the best for epmd though. It can probably be 
ironed out with user feedback.

-- 
Loïc Hoguin
http://ninenines.eu
Author of The Erlanger Playbook,
A book about software development using Erlang



More information about the erlang-questions mailing list