SepShr / MLCSHE

This repo houses the ML-Component Systemic Hazard Envelope project, or MILSCHE (pronounced /'mɪlʃ/).
MIT License
3 stars 0 forks source link

use docker package #32

Closed donghwan-shin closed 2 years ago

donghwan-shin commented 2 years ago

@SepShr I found that there are subprocess.run() for running docker commands. Instead, I found that we can use this docker package: https://docker-py.readthedocs.io/en/stable/index.html#.

For example, you can simply get a short ID (of length 12) of a container named 'pylot' as follows:

import docker
client = docker.from_env()
id = client.containers.get('pylot').short_id

Using subprocess.run() and extracting proper information from its output seems fragile. I recommend using the official docker package. :)

SepShr commented 2 years ago

This issue will be closed since the parallel simulation setup uses the docker library extensively in place of shell scripts.