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

Maxim Sokhatsky maxim@REDACTED
Mon Sep 16 14:26:28 CEST 2013


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: pablo.platt@REDACTED 
> To: erlang-questions@REDACTED 
> 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 erlang-questions@REDACTED 
> http://erlang.org/mailman/listinfo/erlang-questions 		 	   		  


More information about the erlang-questions mailing list