【问题标题】:Ansible docker_container 'no Host in request URL', docker pull works correctlyAnsible docker_container '请求 URL 中没有主机',docker pull 正常工作
【发布时间】:2016-11-30 18:40:00
【问题描述】:

我正在尝试使用 Ansible 剧本在 AWS 上预置我的基础设施。我有这个实例,并且能够配置 docker-engine、docker-py 等,我发誓,昨天这工作正常,从那以后我没有更改代码。

我的剧本的相关部分是:

- 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/子网进行了一些更改,但我能够通过 ssh 连接到实例,并运行 docker pull my-acct-id.dkr.ecr.us-east-1.amazonaws.com/example 没有任何问题。

谷歌搜索并没有让我走得很远,因为我似乎找不到其他人有同样的错误。我想知道发生了什么变化,以及如何解决它!谢谢!

编辑:版本:

  • ansible - 2.2.0.0
  • 码头工人-1.12.3 6b644ec
  • docker-py - 1.10.6

【问题讨论】:

  • 有完全相同的问题。今天早上它对我有用,我没有改变任何东西。我开了一个bug:github.com/ansible/ansible-modules-core/issues/5775
  • 我在访问私有和公共 Docker 注册表时也看到了这一点。这当然是一个令人头疼的问题。

标签: amazon-web-services docker ansible provisioning dockerpy


【解决方案1】:

我遇到了同样的问题。将该主机上的 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,真正的罪魁祸首是请求。这解决了它:

  - name: fix requests
    pip: name=requests version=2.12.1 state=forcereinstall

【讨论】:

  • 这对我有用。奇怪,1.9.0 好像是在几周前发布的。
  • 这对我也有用,但我认为这里有一个大问题我们遗漏了,建议密切关注上面链接的 GitHub 问题 davey_dev。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-11-09
  • 1970-01-01
  • 2014-11-03
  • 2014-04-21
相关资源
最近更新 更多