在ubuntu18.04中
我正在编写python脚本来构建docker映像,然后执行其他操作,main.py
在这里:
from subprocess import run
run('docker build --rm -f "Dockerfile" -t test:latest .')
...
然后发生错误:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python3.6/subprocess.py", line 403, in run
with Popen(*popenargs, **kwargs) as process:
File "/usr/lib/python3.6/subprocess.py", line 709, in __init__
restore_signals, start_new_session)
File "/usr/lib/python3.6/subprocess.py", line 1344, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'docker build --rm -f "Dockerfile" -t test:latest .': 'docker build --rm -f "Dockerfile" -t test:latest .'
将Dockerfile
和main.py
放在一起时,可以直接在shell中运行build命令。