Show HN: Import Docker in Python and Run Anything
blog.deepgram.com
blog.deepgram.com
The hello world:
from sidomo import Container
with Container('ubuntu') as c:
for line in c.run('echo hello from the;echo other side;'):
print(line)"σύντομα" would be the adverb.
What kind of bioinformatics software are you plugging into a webapp?
Nonetheless, it is important to distinguish the need to communicate between programs and the need to programmatically run a piece of software like ffmpeg and getting its output.
For the seconds case, especially in more complex architectures, where you need "interact with software written in another language" it makes sense to explicitly separate this interaction, for example through a broker [0]. In the end, all you need is a way to communicate from Program A that Program B can do some sort of job, and this can be a simple string pointing to a raw video file in a storage like S3, not necessarily the raw file.
[0] http://www.artur-rodrigues.com/tech/2015/06/04/beanstalkd-a-...
That's totally true, but it means the python app can only run in the same container as the process. I thought there were essentially 2 really cool features of this: you don't have to clean up after your (sub)processes and your docker daemon could be running remotely. (e.g., you could distribute tasks to a bunch of servers running your containers)
Our Container class is built so that if you use the `with` statement, container termination is handled automatically even if there's a program fault.
1 The container would need to be privileged so that it could run a docker daemon and containers (sidomo processes) within itself.
2 (the "right" way) Use the host's docker daemon from within the first container by binding the docker.sock to the child container. The first container can start and stop others that run next to it, instead of inside it. This way there's no recursion, and no containers need root privileges.
https://github.com/deepgram/sidomo/blob/7890cde8c5dbf1722311...
It probably wouldn't be much effort to add an options object that is a direct pass-thru to the Docker API. That gives you the availability of all options and helps to future proof it.
I'm not a Python developer, but I've had success doing exactly this in node with the `dockerode` module.
;)