Salt-cloud docker 状态,处理卷

Salt-cloud docker 状态,处理卷

我在用着dockerio 盐状态在 salt minion 上启动 docker 容器。尝试将卷装入我的容器失败。容器正在启动,但卷未绑定。我遗漏了什么?

目标如下:

sudo docker run \
  --volume=/var/run:/var/run:rw \
  --volume=/sys/fs/cgroup/:/sys/fs/cgroup:ro \
  --volume=/var/lib/docker/:/var/lib/docker:ro \
  --publish=8080:8080 \
  --detach=true \
  google/cadvisor

cadvisor sls 文件

cadvisor-image:
   docker.pulled:
     - name: google/cadvisor
     - tag: latest
     - require_in: cadvisor-container
     - force: True

cadvisor-container:
   docker.installed:
     - name: cadvisor
     - hostname: cadvisor
     - image: google/cadvisor
     - ports:
       - "8080/tcp"
     - volumes:
       - /var/run:/var/run
       - /sys/fs/cgroup:/sys/fs/cgroup
       - /var/lib/docker:/var/lib/docker
     - require_in: cadvisor

cadvisor:
   docker.running:
     - container: cadvisor
     - port_bindings:
            "8080/tcp":
                HostIp: ""
                HostPort: "8080"
     - binds:
       /var/run:
         bind: /var/run
         rw: true
       /sys/fs/cgroup:
         bind: /sys/fs/cgroup
       /var/lib/docker:
         bind: /var/lib/docker

版本

love@master:~$ cat /etc/issue
Ubuntu 12.04.1 LTS \n \l

love@master:~$ salt server01 cmd.run "docker version"
server01:
    Client version: 1.1.1
    Client API version: 1.13
    Go version (client): go1.2.1
    Git commit (client): bd609d2
    Server version: 1.1.1
    Server API version: 1.13
    Go version (server): go1.2.1
    Git commit (server): bd609d2

love@master:~$ salt server01 cmd.run "salt-minion --version"
server01:
    salt-minion 2014.1.7

love@master:~$ salt --version
salt 2014.1.7

答案1

Salt 文档有误,没有反映docker-py接口指出GitHub 上的此评论. 缺少尾部斜杠。

     - binds:
      /var/run/:
        bind: /var/run
        ro: False
      /sys/fs/cgroup/:
        bind: /sys/fs/cgroup
        ro: True
      /var/lib/docker/:
        bind: /var/lib/docker
        ro: True

答案2

看起来您在定义“绑定”时遇到了缩进问题。请尝试将其再缩进两个空格,以便嵌套字典的缩进超出父命名空间,而不仅仅是父列表项。

看:http://docs.saltstack.com/en/latest/ref/states/all/salt.states.dockerio.html#salt.states.dockerio.running

- binds:
    /var/log/service: /var/log/service

相关内容