erldocker
erldocker copied to clipboard
docker run
It could be useful to have an equivalent to the docker run command http://docs.docker.io/en/latest/commandline/command/run/ docker_container:run/3 will run a command in a container and gives back the output, possibly warnings and errors too.
Create a container and run a command: docker_container:run(Cmd, Options)
Run a command in existing container: docker_container:run(CID, Cmd, Options)
Cmd = binary/string of the command to execute Options = proplist of options similar to what docker run has.
In addition we could add {timeout, Timeout} Kill the container if it doesn't respond after Timeout. {delete, true} Delete the container after executing the command
This could be implemented using: docker_container:create/1 in case we want to also create a new container. docker_container:start/2 Start the container docker_container:wait/1 Wait for the container to exit. Here we can use a timeout too. docker_container:attach_stream/1 will collect the output. docker_container:stop/1 or docker_container:kill at the end.
I'm looking to implement this feature later.
Right now you can have this functionality through erlsh:
> erlsh:run([erlsh:fdlink_executable(), "/bin/sh", "-c", "docker run base echo hi"]).
{done,0,<<"hi\n">>}