如何将多个文件复制到Docker数据卷中 [英] How to copy multiple files into a docker data volume

查看:270
本文介绍了如何将多个文件复制到Docker数据卷中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这听起来很琐碎,但我找不到将多个文件复制到Docker卷的根文件夹中的简便方法。我正在使用Ubuntu Xenial 16.04 Docker 1.12.1 。例如,如果我有一个容量为 / my_data 的Ubuntu容器:

It may sound trivial but I couldn't find a easy way to copy multiple files into the root folder of a docker volume. I am using Ubuntu Xenial 16.04 and Docker 1.12.1. For example if I have an Ubuntu container with the volume /my_data:

docker run --name my_container -v /my_data -d ubuntu:latest 

在我的主机中,我有一个名为 / tmp / my_data / 的文件夹,其中包含多个文件,我想将所有这些文件复制到卷 / my_data my_container 中。我尝试了以下方法,但没有一种起作用:

In my host machine I have a folder called /tmp/my_data/ with multiple files inside, and I would like to copy all those files into the volume /my_data in my_container. I have tried the following approaches but none of them work:

docker cp /tmp/my_data my_container:/





docker cp /tmp/my_data/* my_container:/my_data/

有人知道解决此问题的方法吗?

Does someone know a work around for this issue?

推荐答案

实际上,这比我容易,只需要在主机路径中添加一个点,它将按预期工作,复制 / my_data 文件夹中的所有文件和文件夹

Actually it was easier than I though, just need to add a dot in the host path and it will work as expected, copying all files and folders within /my_data folder

docker cp /tmp/my_data/. my_container:/my_data

这篇关于如何将多个文件复制到Docker数据卷中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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