Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ansible docker_container 'no Host in request URL', docker pull works correctly

I'm trying to provision my infrastructure on AWS using Ansible playbooks. I have the instance, and am able to provision docker-engine, docker-py, etc. and, I swear, yesterday this worked correctly and I haven't changed the code since.

The relevant portion of my playbook is:

- 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

My {{ docker_registry }} is set to my-acct-id.dkr.ecr.us-east-1.amazonaws.com and the result I'm getting is:

"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"

However, as mentioned, this worked correctly last night. Since then I've made some VPC/subnet changes, but I'm able to ssh to the instance, and run docker pull my-acct-id.dkr.ecr.us-east-1.amazonaws.com/example with no issues.

Googling has led me not very far as I can't seem to find other folks with the same error. I'm wondering what changed, and how I can fix it! Thanks!

EDIT: Versions:

  • ansible - 2.2.0.0
  • docker - 1.12.3 6b644ec
  • docker-py - 1.10.6
like image 668
DTI-Matt Avatar asked Nov 30 '16 18:11

DTI-Matt


1 Answers

I had the same problem. Downgrading docker-compose pip image on that host machine from 1.9.0 to 1.8.1 solved the problem.

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

Per this thread: https://github.com/ansible/ansible-modules-core/issues/5775, the real culprit is requests. This fixes it:

  - name: fix requests
    pip: name=requests version=2.12.1 state=forcereinstall
like image 190
minun09 Avatar answered Nov 02 '22 06:11

minun09