在docker中,我可以发布包含初始数据的卷吗? [英] In docker, can I publish a volumes with initial data?

查看:58
本文介绍了在docker中,我可以发布包含初始数据的卷吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在两个容器之间共享文件存储。从文档中,我已经看到您可以创建和使用这样的卷:

I want to share a file storage between two containers. From the documentation, I've seen that you can create and use volumes like this:

docker volume create --name DataVolume1
docker run -ti --rm -v DataVolume1:/datavolume1 ubuntu

但是我想要容器,以便能够访问一组初始共享数据。码头工人是否支持卷发布?如果不是,这是否意味着我应该在创建卷后手动写入初始数据,还是有其他解决方案将数据与图像一起发布?

However, I want containers to be able to access an initial set of shared data. Does docker support publishing of volumes? If not, does this mean I should write the initial data manually, after creating the volume, or is there another solution for publishing the data along with the images?

推荐答案

使用命名卷(而不是主机卷,也称为绑定装载),泊坞窗将在您挂载的位置将空的命名卷初始化为映像的内容。因此,如果映像中的文件位于/ datavolume1,而DataVolume1为空,则docker会将这些文件复制到指定的卷中。

With a named volume (not with a host volume, aka bind mount) docker will initialize an empty named volume to the contents of the image at the location you mount it. So if you have files in your image at /datavolume1, and DataVolume1 is empty, docker will copy those files into the named volume.

这篇关于在docker中,我可以发布包含初始数据的卷吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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