Starting multiple containers with configs using the Python Docker SDK

494 Views Asked by At

I am using the Docker Python SDK docker-py to create a script that allows starting one or multiple containers (depending on a program argument in a way like script.py --all or script.py --specific_container) and it has to be possible to start each container with its own configuration (image, container_name, etc.) just like in typical docker-compose.yml files. So basically, im trying to do the same what docker-compose does, just with the Python Docker SDK.

I've read that some people are trying to stick with docker-compose by using subprocess but it is not recommended and i would like to avoid this.

I am searching for possibly existing libraries for this but i haven't found anything just yet. Do you know anything i could use? Another option would be to somehow store configuration files for the "specific_container"-profiles and for the "all"-profile as JSON (?) and then parse them and populate the Docker SDK's run method of the Container class, which lets you give all options that you can also give in the docker-compose file.

Maybe someone knows another, better solution?

Thanks in advance guys.

0

There are 0 best solutions below