gpt4 book ai didi

docker - Ansible Docker 连接错误

转载 作者:行者123 更新时间:2023-12-02 18:41:46 41 4
gpt4 key购买 nike

我正在运行 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

关于docker - Ansible Docker 连接错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36584236/

41 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com