[erlang-questions] Not getting exit_status when using open_port with docker
pablo platt
pablo.platt@REDACTED
Mon Sep 16 14:10:48 CEST 2013
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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20130916/ba950d5c/attachment.htm>
More information about the erlang-questions
mailing list