我试图使用Fabric运行docker-compose,但是当我使用Fabric运行docker-compose up命令时,出现以下错误:
[52577] Failed to execute script docker-compose
Traceback (most recent call last):
File "docker-compose", line 6, in <module>
File "compose/cli/main.py", line 71, in main
File "compose/cli/main.py", line 127, in perform_command
File "compose/cli/main.py", line 1080, in up
File "compose/cli/main.py", line 1076, in up
File "compose/project.py", line 475, in up
File "compose/service.py", line 352, in ensure_image_exists
File "compose/service.py", line 1217, in pull
File "compose/progress_stream.py", line 101, in get_digest_from_pull
File "compose/service.py", line 1182, in _do_pull
File "site-packages/docker/api/image.py", line 381, in pull
File "site-packages/docker/auth.py", line 48, in get_config_header
File "site-packages/docker/auth.py", line 96, in resolve_authconfig
File "site-packages/docker/auth.py", line 127, in _resolve_authconfig_credstore
File "site-packages/dockerpycreds/store.py", line 20, in __init__
File "site-packages/dockerpycreds/utils.py", line 12, in find_executable
File "distutils/spawn.py", line 176, in find_executable
File "os.py", line 669, in __getitem__
KeyError: 'PATH'
Failed to up the env
当我从终端运行docker-compose时,它工作正常。
@task
def up(c):
if c.run('docker-compose up', warn=True).failed:
print ("Failed to up the env")
答案 0 :(得分:1)
正如我的评论所建议的,似乎docker-composer up
至少需要执行build
时,需要设置PATH
环境变量。为了解决这个问题,我刚刚将PATH
从当前会话转发到子进程(对不起,PHP!):
$compose = new Process( 'docker-compose up -d', '', [
'VOLUME' => getcwd(),
'PATH' => getenv( 'PATH' ),
] );