gpt4 book ai didi

docker - 了解在Docker中传递给-v的参数

转载 作者:行者123 更新时间:2023-12-02 21:27:58 25 4
gpt4 key购买 nike

如果我在终端中运行以下命令,

$ docker create -v /dbdata --name dbdata training/postgres /bin/true

我有点理解-v命令现在是如何工作的,但是我仍然不太了解上面的命令,本质上我很难理解如何,
-v /dbdata 

可行,命令的那部分实际上在做什么?我真的不明白 -v /dbdata在做什么?

最佳答案

-v /dbdata分配一个Docker volume,并使其在容器内的/dbdata处可用。 Docker“卷”是由Docker存储引擎分配的一部分存储,与您的其余容器文件系统不同。

引用文档:

Data volumes

A data volume is a specially-designated directory within one or more containers that bypasses the Union File System. Data volumes provide several useful features for persistent or shared data:

Volumes are initialized when a container is created. If the container’s base image contains data at the specified mount point, that existing data is copied into the new volume upon volume initialization.

  • Data volumes can be shared and reused among containers.
  • Changes to a data volume are made directly.
  • Changes to a data volume will not be included when you update an image.
  • Data volumes persist even if the container itself is deleted.

Data volumes are designed to persist data, independent of the container’s life cycle. Docker therefore never automatically delete volumes when you remove a container, nor will it “garbage collect” volumes that are no longer referenced by a container.

关于docker - 了解在Docker中传递给-v的参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32273388/

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