docker_container networking issue

27 views
Skip to first unread message

Sonny Heer

unread,
Feb 5, 2017, 11:28:48 AM2/5/17
to Ansible Project
Hi all,

I've been fighting this one for a while.   adding N containers to a custom network.  host1 starts services that listen on 50070.  on host1 I can 'telnet host1.dev 50070' and it works.  host2 is connected to the same 'dev' network, but from host2 connection is refused to host1 on 50070, but ping to host1 works fine.  I've tried exposing/publishing ports.  Although its my understanding inter-container communication on a shared network doesn't need ports exposed as a requirement.

host: linux mint - 4.4.0-62-generic #83-Ubuntu
ansible 2.2.1.0
Docker version 1.12.3, build 6b644ec

relevant files:

  tasks:
    - name: Create dev cluster network
      docker_network:
        name: dev

    - name: Start docker node images
      docker_container:
        image: "test/image"
        name: "host{{ item }}"
        hostname: "host{{ item }}.dev"
        state: started
        privileged: true
        interactive: yes
        restart_policy: always
        exposed_ports: "{{ node_ports }}"
        #published_ports: "{{ node_ports }}"
        networks:
        - name: dev
      with_sequence: count=3


I have another container started the same way that starts a service on 8080, and all containers can connect to that node/port fine.  I'm guessing it has to do with how each service is starting, but i do not control how services are started.  any ideas...?  

Thanks

Sonny Heer

unread,
Feb 8, 2017, 12:09:23 AM2/8/17
to Ansible Project
In case someone else runs into this.  I added 'purge_networks' during the docker_container run and it seems to have fixed the issue.  Apparently this removes the container from all other network interfaces.
Reply all
Reply to author
Forward
0 new messages