0

我可以使用一些帮助。

我的任务是通过 Docker 通过 ansible 安装 check-mk (Nagios)。我设法安装了 docker,但我不能让它通过 ansible 安装 check-mk ......

安装 check-mk 的命令是:

docker container run -dit -p 8080:5000 --ulimit nofile=1024 --tmpfs /opt/omd/sites/cmk/tmp:uid=1000,gid=1000 -v monitoring:/omd/sites --name monitoring -v /etc/localtime:/etc/localtime:ro --restart always checkmk/check-mk-raw:1.6.0-latest

到目前为止,我的代码如下所示:

    - name: Install docker on a Centos 7 machine
      hosts: localhost
      vars:
        create_containers: 1
        default_container_name: docker
        default_container_image: centos
        default_container_command: sleep 1d
        
    tasks:
        - name: Add Docker CE repo
          get_url_
           url: https://download.docker.com/linux/centos/docker-ce.repo
           dest: /etc/yum.repos.d/docker-ce.repo
         
        - name: Install Docker
          yum: name=docker state=latest
          
        - name: Start and enable the Docker daemon
          service: name=docker state=started enabled=yes
          
        - name: Install Docker Module for Python
          pip:
            name: docker
            
        - name: Create a default container
          docker_container:
             name: "{{ default_container_name }}{{ item }}"
             image: "{{ default_container_image }}"
             command: "{{ default_container_command }}"
             state: present
          with_sequence: count={{ create_containers }}
          
          - name: Start a container with a command
            docker_container:
                name: docker1
                image: centos
                command: ["docker container run -dit -p 8080:5000 --ulimit nofile=1024 --tmpfs /opt/omd/sites/cmk/tmp:uid=1000,gid=1000 -v monitoring:/omd/sites --name monitoring -v /etc/localtime:/etc/localtime:ro --restart always checkmk/check-mk-raw:1.6.0-latest"]

但是在启动我的 docker 容器时它会抛出一个错误:

致命的:[本地主机]:失败!=> {"changed": false, "msg": "错误启动容器 fd44b8066dd4d205a1b2883...: http+docker://localhost/v1.26/containers fd44b8066dd4d.../start 的 404 客户端错误:未找到 (" oci 运行时错误:container_linux.go:235:启动容器进程导致“exec:\”/bin/docker\”:stat /bin/docker:没有这样的文件或目录“\n”)“}

谁能告诉我我做错了什么?

4

0 回答 0