【发布时间】:2020-09-27 17:16:18
【问题描述】:
在这个页面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 的目的是什么?
我一直在阅读官方文档:
- https://docs.docker.com/engine/reference/commandline/run/#mount-volume--v---read-only;
- https://docs.docker.com/storage/bind-mounts/;
- 和https://docs.docker.com/storage/volumes/。
我没有看到关于docker run -v [some absolute path directory by itself] [container image name] 的示例和解释。
我理解以下行为:
-
docker run -v [the source, an absolute path on the host to map to a destination within the container]:[the destination, an absolute path in the container] [container image name]; - 和
docker run -v [the source, a docker volume name to map to a destination within the container]:[the destination, an absolute path in the container] [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;主机和容器之间是如何表达的?
【问题讨论】:
-
我找不到任何参考,但看起来
-v /path/on/container只是在容器中创建了一个目录。你可以试试:docker run --rm -v /test debian:stretch ls /显示/test目录。
标签: docker docker-volume docker-run