【问题标题】:Ansible Docker Connection ErrorAnsible Docker 连接错误
【发布时间】:2016-04-12 21:18:41
【问题描述】:

我正在运行 ansible 1.9 版、docker-py 1.1.0 版和 Docker 1.9.1。我在http://registry.myserver.com:5000 运行了一个不安全的私有 docker 注册表。

我有一个 ansible 任务来使用从这个远程注册表中提取的图像来启动一个容器:

---
  - name: Start User Service Container
    docker:
        name: userService
        image: user-service
        registry: registry.myserver.com:5000
        state: running
        insecure_registry: yes
        expose:
          - 8355

但是,这当前返回以下错误:

失败:[bniapp1] => {“改变”:假,“失败”:真} msg: ConnectionError(ProtocolError('Connection aborted.', error(2, 'No such file or directory')),)

详细输出:

<54.229.16.155>
<54.229.16.155> image=discovery-service registry=http://registry.myserver.com:5000 name=discoveryService state=running
<54.229.16.155> IdentityFile=/home/nfrstrctrescd/bni-api.pem ConnectTimeout=10 PasswordAuthentication=no KbdInteractiveAuthentication=no User=centos ControlPath  =/home/nfrstrctrescd/.ansible/cp/ansible-ssh-%h-%p-%r PreferredAuthentications=g  ssapi-with-mic,gssapi-keyex,hostbased,publickey ControlMaster=auto ControlPersis  t=60s
<54.229.16.155>
<54.229.16.155> IdentityFile=/home/nfrstrctrescd/bni-api.pem ConnectTimeout=10 'sudo -k && sudo -H -S -p "[sudo via ansible, key=hxhptjipltjnteknbbxkqgcdwvwshen  p] password: " -u root /bin/sh -c '"'"'echo SUDO-SUCCESS-hxhptjipltjnteknbbxkqgc  dwvwshenp; LANG=C DOCKER_HOST=tcp://127.0.0.1:2376 DOCKER_TLS_VERIFY=1 LC_CTYPE=  C DOCKER_CERT_PATH=/opt/docker/certs /usr/bin/python /home/centos/.ansible/tmp/a  nsible-tmp-1460499148.45-268540710837667/docker; rm -rf /home/centos/.ansible/tm  p/ansible-tmp-1460499148.45-268540710837667/ >/dev/null 2>&1'"'"'' PasswordAuthe  ntication=no KbdInteractiveAuthentication=no User=centos ControlPath=/home/nfrst  rctrescd/.ansible/cp/ansible-ssh-%h-%p-%r PreferredAuthentications=gssapi-with-m  ic,gssapi-keyex,hostbased,publickey ControlMaster=auto ControlPersist=60s
failed: [bniapp1] => {"changed": false, "failed": true}
msg: ConnectionError(ProtocolError('Connection aborted.', error(2, 'No such file or directory')),)

注意:当我在远程服务器上手动运行容器时,图像被拉取并且容器正确启动:

docker run registry.myserver.com:5000/user-service

【问题讨论】:

    标签: docker ansible docker-registry


    【解决方案1】:

    我收到此错误是因为我的 docker 守护程序没有运行。在启动 docker 之前添加以下 ansible 代码为我修复了它:

    # Start Docker Service
    - name: Start Docker service
      service: name=docker state=started
      become: yes
      become_method: sudo
    - name: Boot Docker on startup
      service: name=docker enabled=yes
      become: yes
      become_method: sudo
    

    【讨论】:

    • 你可以打一个电话:service: name=docker state=started enabled=yes
    猜你喜欢
    • 1970-01-01
    • 2014-02-06
    • 1970-01-01
    • 2022-11-10
    • 1970-01-01
    • 2018-04-30
    • 1970-01-01
    • 1970-01-01
    • 2023-02-12
    相关资源
    最近更新 更多