docker - Ansible Docker 连接错误

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

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

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

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

failed: [bniapp1] => {"changed": false, "failed": true} 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 守护程序没有运行。在启动 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

https://stackoverflow.com/questions/36584236/

相关文章:

docker - 将其他Docker节点添加到Shipyard

java - HTable.get(List )是否可以在返回的数组中放入空引用?

plugins - PyCharm Docker部署 “[Errno 2] No such file

docker - Gitlab CI docker环境下无法恢复mono项目的nuget包

docker - 无法使用端口映射通过 Marathon 启动 SonarQube docker 容

docker - Vagrant:在 Windows 上使用 boot2docker 框同步文件夹

eclipse - 使用 Docker 容器化开发环境是否合理?

hadoop - WSO2外部Hadoop

docker - 如何在没有docker客户端的情况下将通过save命令创建的docker镜像推送到

docker - 主机上的一个Java安装可以管理部署在docker容器中的多个应用程序吗