Docker卷和kubernetes卷 [英] Docker volume and kubernetes volume

查看:52
本文介绍了Docker卷和kubernetes卷的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是kubernetes/docker的新手,我想知道kubernetes中的docker volume配置等同于什么.在docker-compose文件中,您可以创建如下卷:

I am new to kubernetes/docker and was wondering what the docker volume configuration equivalent is in kubernetes. In the docker-compose file, you can create volumes like this:

volumes:
   - wordpress/file-abc (1)
   - wordpress:/var/www/html (2)

(1)告诉docker如果/var/www/html中有更改,请保持 wordpress/file-abc 中的内容不变.(2)允许更改除 wordpress/file-abc 以外的所有wordpress文件.

(1) tells docker to keep the content within wordpress/file-abc unchanged if there is a change in /var/www/html. (2) allows changes to all the wordpress files except wordpress/file-abc.

在kubernetes中创建持久卷时,相当于(1)的kubernetes是什么?Kubernetes中的volumeMount是否等于(2)?

What is the kubernetes equivalent of (1) when creating persistent volumes in kubernetes? Are volumeMounts in Kubernetes the equivalent for (2)?

推荐答案

在Docker中,实际上,卷是由docker通过三种方式管理的,1.体积2.装订3.tmpfs.

In Docker, Actually, volume is managed by docker using three way, 1.volume 2.Bind mount 3.tmpfs.

#卷:当您在docker中使用-v和--volume而不引用主机上的完整路径或相对路径时,docker将创建一个新目录卷,该卷是在主机上Docker的存储目录中创建的,Docker管理该目录的内容.

# volume: when you use -v and --volume in docker without referencing the full or relative path on the host machine then docker will create volume which is new directory and its is created within Docker’s storage directory on the host machine, and Docker manages that directory’s contents.

#绑定安装:当您将-v或--volume与主机上其完整或相对路径所引用的文件或目录一起使用时,docker只会将该主机目录与所提到的容器目录映射.

# Bind mount: when you use -v or --volume with the file or directory which is referenced by its full or relative path on the host machine then docker will just map the that host machine directory with the mentioned container directory.

#tmpfs:创建带有tmpfs挂载的容器时,该容器可以在该容器的可写层之外创建文件.有关更多详细信息,请参见此

#tmpfs: When you create a container with a tmpfs mount, the container can create files outside the container’s writable layer.for more detail see this document.

在Kubernetes中:卷不仅限于磁盘上的目录.您可以在不同的文件系统中创建不同类型的卷.您可以在此处获取详细信息.您可以将docker bind挂载与Kubernetes卷类型的hostpath进行比较.详情请参见此处.

In Kubernetes: Volume is not only restricted to a directory on disk. You can create a different type of volume in different filesystem. you can get the details supported volume here. You can compare docker bind mount with Kubernetes volume type hostpath.see details here.

在kubernetes中创建持久卷的答案?

The answer of when creating persistent volumes in kubernetes?

当您需要使数据跨容器持久化时,可以使用任何卷类型来创建耐性卷.

when you need to have your data persistent across container, you can create presistant volume using any volume type.

Kubernetes中的volumeMount是否等于(2)?

Are volumeMounts in Kubernetes the equivalent for (2)?

否,在kubernetes中使用volumeMounts来挂载由任何卷类型创建的卷.例如:

NO,volumeMounts is used in kubernetes to mount a volume that is created by a any volume type. for example:

volumes:
  - name: test-volume
    # This GCE PD must already exist.
    gcePersistentDisk:
      pdName: my-data-disk
      fsType: ext4

立即安装

    volumeMounts:
    - mountPath: /test-pd
      name: test-volume

这篇关于Docker卷和kubernetes卷的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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