Ansible docker_container gives “Error getting network id”

I’m running an ansible playbook from an ansible control located in a docker container. The playbook should create another docker container and attach it to a bridge network. The docker daemon is located on the host machine from which I launched the ansible control container.

My playbook is simple and I can ansible ping the host:

  • Docker, web app static files. Best practices?
  • bluemix container KO with ip public but OK in local
  • How to backup the cassandra running in docker container
  • IBM Bluemix Containers : cf ic stats not working
  • Why does different container of same elasticsearch image on docker exits out?
  • Add/edit files inside a docker container using a remotely?
  •   - hosts: docker
          become: myuser
          connection: local
          gather_facts: no        
              - name: Start Node container, connect to network
                  name: node1
                  hostname: node1
                  docker_host: tcp://
                  image: ubuntu-java
                  state: started
                  tty: yes
                  detach: yes
                  restart_policy: on-failure
                     - name: my-network 

    I’m getting this error:

    “msg”: “Error getting network id for my-network – (‘Connection
    aborted.’, error(104, ‘Connection reset by peer’))”

    UPDATE 1/19/2017:

    I can now do this. The provsioning playbook looks something like this:

    - hosts: docker-host
        - ~/resources/vars/docker-inst-setup.yml
        - name: debug check
            msg: "container is {{ item.cont_name }}"
          with_items: "{{ inst_types }}"
        - name: Start container, connect to network
          become: true
          become_user: "{{ ansible_user_id }}"
            name: "{{ item.cont_name }}" 
            hostname: "{{ item.cont_name }}"
            image: gf-node:latest
            state: started
            tty: yes
            detach: yes
            restart_policy: on-failure
            network_mode: bridge
            volumes: /home/me/.ssh
            volumes_from: ansible-master 
          register: ansible_docker_container
          with_items: "{{ inst_types }}"


    • First I had to set up .ssh between ansible-master and the docker containers I want to provision, which I do in the dockerfiles.
    • docker-host is defined in inventory file
    • register: ansible_docker_container just returns some facts from docker_container. It can be printed later in a debug task, but its not very helpful.

    docker-inst-setup.yml looks something like:

      - {cont_name: "gf-das", cont_count: 1}
      - {cont_name: "gf-build-node", cont_count: 1}

    The process is complicated but I wrote it all up in this blog article. I hope this helps.

  • Docker instance cannot run images anymore and unable to reclaim free space
  • What is a Docker tag (looking for a definition)?
  • publish a web api based on core RC2 on docker
  • Unable to create docker virtual machine
  • docker started via shelljs not responding to input in interactive mode
  • Permisson error with mongo when running docker
  • Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.