简体   繁体   中英

Calling docker-compose with python subprocess ends with FileNotFoundError 'docker-compose'

I am quite new to docker so I ran into some error state with my python script. It should listen for a couple of docker containers which have been started with docker-compose up using a specific yaml file.

The ignition process is working but when one container goes down another one (observing entity) should revive it with, say docker-compose start deadmodule

My setup:

  • OS: Windows 10
  • Docker: 2.0.0.0-win78 (28905)
  • Docker Engine: 18.09.0
  • Compose: 1.23.1
  • Python 3.6

I am trying this:

subprocess.call('docker-compose',
                'start',
                'deadmodule')

And I tried it also with Popen(['docker-compose', 'start', 'deadmodule'], stdout=PIPE, stderr=PIPE)

However it ends with this:

FileNotFoundError: [Errno 2] No such file or directory: 'docker-compose': 'docker-compose'

当您不使用shell=True ,不会自动添加文件结尾,因此您需要调用的是docker-compose.exe ,而不是docker-compose.exe docker-compose

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM