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:

  • How to connect usb wireless interface to a Docker container on Mac OSX?
  • How Docker and Ansible fit together to implement Continuos Delivery/Continuous Deployment
  • How to increase the size of the /dev/shm in docker container
  • How do you add a volume to a container in the IBM Bluemix Docker cloud?
  • Docker container fails to start
  • Docker crash test with many containers of the same image
  •   - 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.

  • Cannot access Google Container Registry from Google Compute Engine
  • Connecting to Oracle XE running on Docker
  • process exit code 127 while running a bash script by java service in docker
  • How to keep ubuntu image running?
  • Create mongodb container w default data
  • Running multiple dev projects in docker containers with nginx-proxy
  • Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.