【发布时间】:2014-06-10 18:37:41
【问题描述】:
我认为这在几个月前还有效。常规命令行 docker:
>> docker run --name 'mycontainer' -d -v '/new' ubuntu /bin/bash -c 'touch /new/hello.txt'
>> docker run --volumes-from mycontainer ubuntu /bin/bash -c 'ls new'
>> hello.txt
按预期工作,但我无法让它在 docker-py 中工作:
from docker import Client #docker-py
import time
docker = Client(base_url='unix://var/run/docker.sock')
response1 = docker.create_container('ubuntu', detach=True, volumes=['/new'],
command="/bin/bash -c 'touch /new/hello.txt'", name='mycontainer2')
docker.start(response1['Id'])
time.sleep(1)
response = docker.create_container('ubuntu',
command="/bin/bash -c 'ls new'",
volumes_from='mycontainer2')
docker.start(response['Id'])
time.sleep(1)
print(docker.logs(response['Id']))
..总是告诉我新的不存在。 volumes-from 应该如何用 docker-py 完成?
【问题讨论】: