使用salt在Docker容器中挂载主机目录的正确方法

使用下面的命令行:

docker run -ti -v /hostDirectory:/containerDirectory 

我可以将主机上的目录映射到容器上的目录。

如何使用saltstack的dockerng获得相同的效果? 我没有看到引用主机卷目录映射到容器目录的文档中的任何地方,它看起来像dockerng只支持使用docker创build的卷。

dockerng中的相关参数在dockerng.running函数下重命名为“binds”

 binds Files/directories to bind mount. Each bind mount should be passed in the format <host_path>:<container_path>:<read_only>, where <read_only> is one of rw (for read-write access) or ro (for read-only access). foo: dockerng.running: - image: bar/baz:latest - binds: /srv/www:/var/www:ro,/etc/foo.conf:/usr/local/etc/foo.conf:rw Binds can be passed as a YAML list instead of a comma-separated list: foo: dockerng.running: - image: bar/baz:latest - binds: - /srv/www:/var/www:ro - /home/myuser/conf/foo.conf:/etc/foo.conf:rw Optionally, the read-only information can be left off the end and the bind mount will be assumed to be read-write. The example below is equivalent to the one above: foo: dockerng.running: - image: bar/baz:latest - binds: - /srv/www:/var/www:ro - /home/myuser/conf/foo.conf:/etc/foo.conf