我正在尝试运行 docker 容器将文件从卷复制到本地文件夹:
import docker
client = docker.from_env()
stdout = client.containers.run(
"alpine",
mounts=[
docker.types.Mount(
"/data_to",
os.path.abspath("./data_localhost"),
'bind')
],
volumes={
volume_name: {'bind': '/data_from', 'mode': 'rw'}
},
working_dir='/data_from',
command=["cp", "/data_from/*", "/data_to/"]
# command=["touch", "/data_to/a"]
# command=["ls", "/data_from/"]
)
logging.info(stdout.decode("utf-8"))
但我明白了
docker.errors.ContainerError: Command '['cp', '/data_from/*', '/data_to/']' in image 'alpine' returned non-zero exit status 1: b"cp: can't stat '/data_from/*': No such file or directory\n"
它似乎没有正确处理星号。为什么是这样?
我可以正确地 ls 的内容,也可以从容器内/data_from/
写入数据。/data_to/