Ansible docker_container出现“请求URL中没有主机”,但docker pull工作正常。

5
我将使用Ansible playbooks在AWS上配置基础设施。我已经有了实例,可以提供docker-engine、docker-py等服务。昨天这些服务能够正常运行,但自那时以来我没有更改代码。
我的playbook的相关部分如下:
- name: Ensure AWS CLI is available
  pip:
    name: awscli
    state: present
  when: aws_deploy
- block:
  - name: Add .boto file with AWS credentials.
    copy:
      content: "{{ boto_file }}"
      dest: ~/.boto
    when: aws_deploy
  - name: Log in to docker registry.
    shell: "$(aws ecr get-login --region us-east-1)"
    when: aws_deploy
  - name: Remove .boto file with AWS credentials.
    file:
      path: ~/.boto
      state: absent
    when: aws_deploy
  - name: Create docker network
    docker_network:
      name: my-net
  - name: Start Container
    docker_container:
      name: example
      image: "{{ docker_registry }}/example"
      pull: true
      restart: true
      network_mode: host
      volumes:
        - /etc/localtime:/etc/localtime:ro
        - /etc/timezone:/etc/timezone

我的{{ docker_registry }}已设置为my-acct-id.dkr.ecr.us-east-1.amazonaws.com,我得到的结果是:

"msg": "Error pulling my-acct-id.dkr.ecr.us-east-1.amazonaws.com/example - code: None message: Get http://: http: no Host in request URL"

然而,正如之前所提到的,这在昨晚仍然能够正常工作。自那时以来,我进行了一些VPC/subnet更改,但我仍能够通过ssh连接到实例,并使用 docker pull my-acct-id.dkr.ecr.us-east-1.amazonaws.com/example 命令进行运行,并且没有出现任何问题。
经过搜索,我没有找到其他遇到相同错误的人,因此我想知道发生了什么变化,并如何解决该问题!谢谢!
编辑:版本:
  • ansible - 2.2.0.0
  • docker - 1.12.3 6b644ec
  • docker-py - 1.10.6

1
遇到了完全相同的问题。今天早上还好好的,我什么都没改过。我已经提交了一个错误报告:https://github.com/ansible/ansible-modules-core/issues/5775 - davegallant
当我访问私有和公共的Docker注册表时,我也遇到了这个问题。这确实是一个令人困惑的问题。 - user1836542
1个回答

4

我遇到了同样的问题。将该主机上的docker-compose pip镜像从1.9.0降级到1.8.1解决了问题。

- name: Install docker-compose
  pip: name=docker-compose version=1.8.1

根据此线程:https://github.com/ansible/ansible-modules-core/issues/5775,罪魁祸首是requests。以下修复该问题:
  - name: fix requests
    pip: name=requests version=2.12.1 state=forcereinstall

这对我有用。奇怪的是,看起来1.9.0在几周前发布了。 - davegallant
这个方法对我也有效,尽管我认为我们忽略了一个很大的问题,建议留意davey_dev以上链接到的GitHub问题。 - DTI-Matt

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接