|
Post by account_disabled on Jan 28, 2024 11:59:34 GMT 2
否存在该卷 卷检查意 我们甚至可以在挂载点列出的路径上查看主机上的数据。但是 我们应该避免更改它们 因为如果应用程序或容器不知道更改 可能会导致数据损坏。 然后我们将启动一个新容器并附加 验证内容 猫 在此示例中 我们创建了一个卷 将其附加到容器 并验证了其耐用性。 创建删除容器后仍存在的卷 在下一个示例中 我们将创建一个卷 在创建容器的同时 删除该容器 然后将该卷附加到新容器。 我们将使用 命令使用基本 映像创建一个新容器。 将为我们提供一个终端 而 将允许我们与其交互。为了清楚起见 我们将使用 来标识容器。 标志将允许我们创建一个新卷 我们将其称为 。我们将使用冒号将其名称与卷应安装在容器中的路径分隔开。最后 我 墨西哥数据 们将指定一个基础 镜像 并依赖 基础镜像 中的默认命令 来进入 注意 标志非常灵活。它可以通过轻微的语法修改来绑定或命名卷。如果第一个参数。 以 或 开头 则您正在创建绑定。删除它 您将为您的卷命名。例如 挂载宿主机目录 在 创建一个名为 的卷 但不连接到主机。 在容器中 我们将一些数据写入卷 示例 猫 让我们离开容器 出口 重新启动容器后 该卷将自动挂载 让我们检查一下该卷是否已实际安装并且我们的数据仍然可用 猫 最后 我们出去清理一下 出口 如果卷已分配有容器 则 将不允许我们删除该卷。让我们看看当我们尝试这样做时会发生什么。
|
|