使用命令行实用程序的 python 子进程启动 Docker
Start Docker with python subprocess for a command line utility
我很困惑为什么下面的代码 returns 出错了:
import subprocess
a = subprocess.Popen(["docker-compose down weather-data"])
a.wait()
我得到一个错误:
FileNotFoundError: [Errno 2] No such file or directory: 'docker-compose down weather-data'
您的命令需要在一个数组中,命令的每个部分都作为数组中的一个元素。例如:
import subprocess
a = subprocess.Popen(["docker-compose", "down", "weather-data"])
a.wait()
如果全部在一个字符串中,Python 正在尝试查找名为“docker-compose down weather-data”的单个可执行文件。
我很困惑为什么下面的代码 returns 出错了:
import subprocess
a = subprocess.Popen(["docker-compose down weather-data"])
a.wait()
我得到一个错误:
FileNotFoundError: [Errno 2] No such file or directory: 'docker-compose down weather-data'
您的命令需要在一个数组中,命令的每个部分都作为数组中的一个元素。例如:
import subprocess
a = subprocess.Popen(["docker-compose", "down", "weather-data"])
a.wait()
如果全部在一个字符串中,Python 正在尝试查找名为“docker-compose down weather-data”的单个可执行文件。