I am using docker compose to create a network of containers, where one of the containers requests another to run a process. The client also has to monitor these process in case of errors or when it completes. My approach is to use python's subprocess Popen like this:
process = subprocess.Popen(cmd,stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
where cmd is ['docker-compose', 'exec', 'service2', 'sh', '-c', 'cp sourcefile /destination && python run.py']
But I get this error
[Errno 2] No such file or directory: 'docker-compose': 'docker-compose'
I tried executing the same command in bash mode on the client container and got
bash: docker-compose: command not found. I thought of doing a dind, but is that really necessary? This command works on my host machine docker-compose run --rm service2 python apples.py shell. What's the right approach bearing in mind I need to query the returncode of the process running in container service2 from service1 at anytime. I declared a bridge-network. Thanks
/usr/bin/docker-compose.