Python社区  »  docker

Jenkins Docker_登录Ansible Playbook:权限被拒绝

Marko Zadravec • 1 周前 • 13 次点击  

我想把Docker容器复制到Jenkins的Docker注册表中。

当我执行Ansible Playbook时,我得到:

"msg": "Error connecting: Error while fetching server API version: ('Connection aborted.', error(13, 'Permission denied'))"

我想ansible是在jenkins用户下运行的,因为 link ,并且由于日志文件:

<127.0.0.1> ESTABLISH LOCAL CONNECTION FOR USER: jenkins

因为负责的剧本试图 docker_login ,我理解用户jenkins需要能够连接到docker。

所以我将Jenkins添加到Docker用户: enter image description here

我不明白为什么拒绝批准

整个日志詹金斯文件:

TASK [Log into Docker registry] 
************************************************
task path: /var/jenkins_home/workspace/.../build_docker.yml:8
Using module file /usr/lib/python2.7/dist- 
packages/ansible/modules/core/cloud/docker/docker_login.py
<127.0.0.1> ESTABLISH LOCAL CONNECTION FOR USER: jenkins
<127.0.0.1> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo ~/.ansible/tmp/ansible-tmp-1543388409.78-179785864196502 `" && echo ansible-tmp-1543388409.78-179785864196502="` echo ~/.ansible/tmp/ansible-tmp-1543388409.78-179785864196502 `" ) && sleep 0'
<127.0.0.1> PUT /tmp/tmpFASoHo TO /var/jenkins_home/.ansible/tmp/ansible-tmp-1543388409.78-179785864196502/docker_login.py
<127.0.0.1> EXEC /bin/sh -c 'chmod u+x /var/jenkins_home/.ansible/tmp/ansible-tmp-1543388409.78-179785864196502/ /var/jenkins_home/.ansible/tmp/ansible-tmp-1543388409.78-179785864196502/docker_login.py && sleep 0'
<127.0.0.1> EXEC /bin/sh -c '/usr/bin/python /var/jenkins_home/.ansible/tmp/ansible-tmp-1543388409.78-179785864196502/docker_login.py; rm -rf "/var/jenkins_home/.ansible/tmp/ansible-tmp-1543388409.78-179785864196502/" > /dev/null 2>&1 && sleep 0'
fatal: [localhost]: FAILED! => {
"changed": false, 
"failed": true, 
"invocation": {
    "module_args": {
        "api_version": null, 
        "cacert_path": null, 
        "cert_path": null, 
        "config_path": "~/.docker/config.json", 
        "debug": false, 
        "docker_host": null, 
        "email": null, 
        "filter_logger": false, 
        "key_path": null, 
        "password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER", 
        "reauthorize": false, 
        "registry_url": "https://registry.docker....si", 
        "ssl_version": null, 
        "timeout": null, 
        "tls": null, 
        "tls_hostname": null, 
        "tls_verify": null, 
        "username": "jenkins"
    }, 
    "module_name": "docker_login"
}, 
"msg": "Error connecting: Error while fetching server API version: ('Connection aborted.', error(13, 'Permission denied'))"
}
to retry, use: --limit @/var/jenkins_home/workspace/.../build_docker.retry

整个责任剧本

---
- hosts: localhost
  vars:
    git_branch: "{{ GIT_BRANCH|default('development') }}"
  tasks:
  - name: Log into Docker registry
    docker_login:
      registry_url: https://registry.docker.....si
      username: ...
      password: ....

enter image description here

Python社区是高质量的Python/Django开发社区
本文地址:http://www.python88.com/topic/40209
 
13 次点击  
分享到微博
文章 [ 1 ]  |  最新文章 1 周前
Marko Zadravec
Reply   •   1 楼
Marko Zadravec    9 月前

如果有人有同样的问题我找到了解决办法…

我的注册表没有有效的https证书。所以,你需要补充

{
    "insecure-registries" : [ "https://registry.docker.....si" ]
}

在/etc/docker/daemon.json中