[erlang-questions] Not getting exit_status when using open_port with docker

pablo platt <>
Tue Sep 17 00:42:51 CEST 2013


I'll try eerlexec.

Thanks


On Mon, Sep 16, 2013 at 11:08 PM, OvermindDL1 <> wrote:

> Look at erlexec instead.  open_port is not designed for lifetime
> management like that.
> On Sep 16, 2013 7:31 AM, "pablo platt" <> wrote:
>
>> I looked at erlsh. It uses open_port with a loop like I'm using in my
>> code so my question still stands.
>> Why I'm not getting the exit message from the "docker run" command?
>>
>> erldocker looks nice but I couldn't find the equivalent of "docker run"
>> without starting, attaching, detaching and destroying a container.
>> I'm not sure how to do it manually because I need to know when the
>> container exits which docker run does.
>>
>>
>> On Mon, Sep 16, 2013 at 3:26 PM, Maxim Sokhatsky <> wrote:
>>
>>> First of all you do it wrong just because of two things :)
>>>
>>> The first thing is erlsh library: https://github.com/proger/erlsh
>>> And the second is erldocker library: https://github.com/proger/erldocker
>>>
>>> Moreover if you are interesting in your own Erlang PaaS
>>> you could read the sources of the first Erlang PaaS:
>>>
>>> https://github.com/voxoz
>>>
>>> Hope this save your time :)
>>>
>>> /maxim
>>>
>>> ________________________________
>>> > Date: Mon, 16 Sep 2013 15:10:48 +0300
>>> > From: 
>>> > To: 
>>> > Subject: [erlang-questions] Not getting exit_status when using
>>> > open_port with docker
>>> >
>>> > Hi,
>>> >
>>> > I'm calling "docker run" from Erlang.
>>> > http://docs.docker.io/en/latest/commandline/command/run/
>>> > I'm using open_port instead of os:cmd to be able to limit the
>>> execution time.
>>> > I'm getting the output of the command
>>> > but the do_read just keep going and I'm not able to get an exit status
>>> > from the command.
>>> >
>>> > When running "echo 'test'" I'm getting {exit_status, 0}.
>>> > When running the "docker run" command in the shell, I'm getting the
>>> > output and it exits.
>>> > When running any other docker command like "docker ps" I'm getting the
>>> > exit signal.
>>> >
>>> > Is this a problem with how I'm using open_port or something wrong with
>>> > the "docker run" command?
>>> >
>>> > -module(test).
>>> >
>>> > -export([run/0]).
>>> >
>>> > run() ->
>>> > Cmd = "sudo docker run ubuntu echo \"test\"",
>>> > Port = open_port({spawn, Cmd}, [binary, exit_status]),
>>> > do_read(Port, <<>>).
>>> >
>>> > do_read(Port, Data) ->
>>> > receive
>>> > {Port,{data, NewData}} ->
>>> > io:format("data ~p~n", [NewData]),
>>> > do_read(Port, <<Data/binary, NewData/binary>>);
>>> > {Port,{exit_status, 0}} ->
>>> > io:format("exit~n"),
>>> > case Data of
>>> > <<"">> -> <<"ok">>;
>>> > _ -> Data
>>> > end;
>>> > E ->
>>> > io:format("Something: ~p~n", [E])
>>> > end.
>>> >
>>> >
>>> > _______________________________________________ erlang-questions
>>> > mailing list 
>>> > http://erlang.org/mailman/listinfo/erlang-questions
>>> _______________________________________________
>>> erlang-questions mailing list
>>> 
>>> http://erlang.org/mailman/listinfo/erlang-questions
>>>
>>
>>
>> _______________________________________________
>> erlang-questions mailing list
>> 
>> http://erlang.org/mailman/listinfo/erlang-questions
>>
>>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20130917/cc0682d6/attachment.html>


More information about the erlang-questions mailing list