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

Correct way to mount a host directory in a docker container using salt

使用下面的命令行:

docker run -ti -v /hostDirectory:/containerDirectory

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

如何获得相同的效果using saltstack's dockerng?我在文档中没有看到任何地方引用主机卷目录映射到容器上的目录,看起来 dockerng 只支持使用 docker.

创建的卷

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