'docker run' 使用挂载卷选项 '-v' 和单个目录作为参数(没有源和目标用冒号分隔(“:”))

'docker run' using mount volume option '-v' with single directory as parameter (no source and destination split with colon mark (":"))

在此页面上 https://mherman.org/blog/dockerizing-an-angular-app/ ,

在本教程的某些时候,有这个命令来启动容器: $ docker run -v ${PWD}:/app -v /app/node_modules -p 4201:4200 --rm example:dev.

我不明白 -v /app/node_modules 部分。如果没有用冒号分隔的源和目标,-v 的目的是什么?

我一直在阅读官方文档:

我没有看到关于 docker run -v [some absolute path directory by itself] [container image name] 的示例和解释。

我了解以下行为:

但我不明白它的预期行为是什么:docker run -v [some absolute path directory by itself] [container image name]

什么是-v [some absolute path directory by itself],喜欢-v /app/node_modules;它如何在主机和容器之间进行连接?

docker run命令支持大部分Dockerfile命令,其中VOLUME

The VOLUME instruction creates a mount point with the specified name and marks it as holding externally mounted volumes from native host or other containers.

The docker run command initializes the newly created volume with any data that exists at the specified location within the base image.

通常,这叫做anonymous volume

Anonymous volumes have no specific source so when the container is deleted, instruct the Docker Engine daemon to remove them.

--volume is given a single argument 时,该行为会在容器中创建一个空目录

When the host directory of a bind-mounted volume doesn’t exist, Docker will automatically create this directory on the host for you.