如何在Dockerfile中删除卷 [英] How to remove a volume in a Dockerfile

查看:43
本文介绍了如何在Dockerfile中删除卷的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到了与此处相同的问题: mkdir .ssh在Dockerfile中,文件夹不存在吗?

I'm experiencing the same problem as found here: mkdir .ssh in a Dockerfile, folder is not there?

我想知道我的dockerfile是否可以删除其父声明的卷?

I'm wondering if there is a way for my dockerfile to remove a volume declared by its parent?

我的理由是:该卷已声明要装入外部数据库,我正在创建的映像用于测试目的,并且包含该卷内部的数据.理想情况下,我不想在我的入口点填充它,因为这是一项昂贵的操作.

My reasoning for this is that; the volume was declared to mount to an external database, the image I'm creating is for testing purposes and contains the data present for the volume internally. Ideally I don't want to have to populate this in my entry point as it's an expensive operation.

推荐答案

另请参见如何在Docker映像中删除配置卷

实际上,在使用生产中的图像进行修改以进行测试时,我确实有一个非常相似的用例.唯一的机会是修改父图像的元数据.根据需要,我为此创建了一个小脚本,请查看 docker-copyedit 可以帮助您.

Actually I did have a very similar use case in using an image from production that would be modified for testing. The only chance is to modify the metadata of the parent image. As I need to that regulary, I have created a little script for that, have a look at docker-copyedit if that can help you.

这篇关于如何在Dockerfile中删除卷的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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