2016-04-12 93 views
1

我正在運行正式版本1.9,docker-py version 1.1.0和Docker 1.9.1。我有一個私人的不安全碼頭註冊表,運行在http://registry.myserver.com:5000Ansible 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 

然而,這是目前返回以下錯誤:

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')),) 

注意:當我在遠程服務器上手動運行容器時,th e圖像被拉出,容器正確啓動:

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

回答

0

我得到這個錯誤,因爲我的碼頭守護程序沒有運行。在啓動碼頭服務器之前添加以下安全代碼:

# 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 
+1

您可以進行單個調用:'service:name = docker state = started enabled = yes' –