将通配符的文件夹从docker容器复制到主机 [英] Copy folder with wildcard from docker container to host

查看:3585
本文介绍了将通配符的文件夹从docker容器复制到主机的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

创建备份脚本以将mongodb转储到容器中,我需要将文件夹复制到容器外部,Docker cp 似乎无法使用通配符: p>

Creating a backup script to dump mongodb inside a container, I need to copy the folder outside the container, Docker cp doesn't seem to work with wildcards :

docker cp mongodb:mongo_dump_* .

终端中抛出以下内容:

来自守护程序的错误响应:lstat / var / lib / docker / aufs / mnt / SomeHash / mongo_dump_ *:没有这样的文件
或目录

Error response from daemon: lstat /var/lib/docker/aufs/mnt/SomeHash/mongo_dump_*: no such file or directory

使用通配符与cp命令有任何变通方法吗?

Is there any workaround to use wildcards with cp command ?

推荐答案

你可以将mongo转储文件创建到容器内的文件夹中,然后复制文件夹:这是一个解决方法。

You can create the mongo dump files into a folder inside the container and then copy the folder: this is a workaround.

似乎没有办法 strong>使用通配符与docker cp命令 https://github.com/docker/docker/issues / 7710

我认为处理你想要做的最好的方法是使用码头卷,所以你可以直接从容器中保存文件进入您的主机文件夹,而不使用任何其他命令: https://docs.docker.com/engine/userguide/containers/dockervolumes/

I think the best way to handle what you want to do is to use docker volumes, so you can directly save the files from the container into your host folder without using any other command: https://docs.docker.com/engine/userguide/containers/dockervolumes/

这篇关于将通配符的文件夹从docker容器复制到主机的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆