如何找到配置到docker * image *本身的卷? [英] How do you find volumes configured into the docker *image* itself?

查看:141
本文介绍了如何找到配置到docker * image *本身的卷?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

此问题询问在容器中列出卷。

但是我正在寻找的是,您如何将卷配置成图像本身,而不先创建容器?

But what I'm looking for here is, how do you find volumes configured into an image itself, without creating a container first?

这个想法是,我想知道在允许容器从该映像运行之前,映像到主机文件系统的映像可能会做什么。

The idea is, I want to know what an image might do with volumes mapped to the host file system, before allowing a container to run from that image.

官方的 postgres 图像是一个很好的例子。当您启动此映像的容器时,它会自动在 / var / lib / postgresql / data 中创建一个卷。在开始一个容器之前有没有办法解决这个问题?

The official postgres image is a good example. When you start a container of this image, it automatically creates a volume at /var/lib/postgresql/data. Is there a way to figure that out before starting a container?

推荐答案

当然可以。您可以在图像上使用 docker inspect 命令。例如:

Sure. You can use the docker inspect command on the image. For example:

$ docker inspect postgres
[...]
        "Volumes": {
            "/var/lib/postgresql/data": {}
        },
[...]

如果您想避免所有其他输出,可以使用:

If you want to avoid all the other output, you can use:

$ docker inspect --format '{{.ContainerConfig.Volumes}}' postgres
map[/var/lib/postgresql/data:{}]

这篇关于如何找到配置到docker * image *本身的卷?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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