Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Running docker-compose from python [duplicate]

I am looking for a way to run a docker-compose file from python script. I looked in Docker SDK for python, but i didn't found anything about docker-compose. So, is there a way to run a docker-compose file from python script?

like image 880
Nidal Avatar asked Dec 09 '18 22:12

Nidal


People also ask

How do I run multiple copies of compose file on the same host?

Compose uses the project name to create unique identifiers for all of a project's containers and other resources. To run multiple copies of a project, set a custom project name using the -p command line option or the COMPOSE_PROJECT_NAME environment variable.

Can I run 2 Docker compose files?

Using Multiple Docker Compose Files Use multiple Docker Compose files when you want to change your app for different environments (e.g., dev, staging, and production) or when you want to run admin tasks against a Compose application.

How do I recreate a docker compose container?

If you want to force Compose to stop and recreate all containers, use the --force-recreate flag. If the process encounters an error, the exit code for this command is 1 . If the process is interrupted using SIGINT (ctrl + C) or SIGTERM , the containers are stopped, and the exit code is 0 .


1 Answers

The question was answered by @cricket_007:

It's not a supported use case, nor meant to be used that way. github.com/docker/compose/issues/4542#issuecomment-283191533 You could just use subprocess module to shell out to the commands, or use docker-py directly – cricket_007 Dec 9 '18 at 22:36

And the answer was accepted by the OP:

Ok so, I think the simplest way for me is to use subprocess module. Thanks for your response :) – Nidal

like image 147
2 revs, 2 users 67% Avatar answered Sep 30 '22 02:09

2 revs, 2 users 67%