gpt4 book ai didi

docker - Docker 中的绑定(bind)挂载和主机卷是一样的吗?

转载 作者:行者123 更新时间:2023-12-03 08:15:47 28 4
gpt4 key购买 nike

我在各种文章中看到过术语“绑定(bind)安装”和“主机卷”,但没有提到它们是否是同一件事。但从它们的功能来看,它们看起来几乎是一样的。谁能回答一下是不是同一个东西?如果不是,有什么区别?

引用:

Docker Docs - Use bind mounts

https://blog.logrocket.com/docker-volumes-vs-bind-mounts/

最佳答案

它们是不同的概念。

bind mounts 中所述:

Bind mounts have been around since the early days of Docker. Bind mounts have limited functionality compared to volumes. When you use a bind mount, a file or directory on the host machine is mounted into a container. The file or directory is referenced by its absolute path on the host machine. By contrast, when you use a volume, a new directory is created within Docker’s storage directory on the host machine, and Docker manages that directory’s contents.

正如 volumes 中提到的:

Volumes are the preferred mechanism for persisting data generated byand used by Docker containers. While bind mounts are dependent on thedirectory structure and OS of the host machine, volumes are completelymanaged by Docker. Volumes have several advantages over bind mounts:

  • Volumes are easier to back up or migrate than bind mounts.
  • You can manage volumes using Docker CLI commands or the Docker API.
  • Volumes work on both Linux and Windows containers.
  • Volumes can be more safely shared among multiple containers.
  • Volume drivers let you store volumes on remote hosts or cloud providers, to encrypt the contents of volumes, or to add other functionality.
  • New volumes can have their content pre-populated by a container.
  • Volumes on Docker Desktop have much higher performance than bind mounts from Mac and Windows hosts.

关于docker - Docker 中的绑定(bind)挂载和主机卷是一样的吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69496662/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com