Re: [ansible-project] docker run --net ... --ip

8 views
Skip to first unread message

Fernando González

unread,
Dec 8, 2017, 4:52:27 PM12/8/17
to ansible...@googlegroups.com

El 26 nov. 2017 1:49 p. m., "Teresa e Junior" <teresa...@gmail.com> escribió:
I am trying to give my pi-hole container a static IP address. The following works the way I want:

# docker network create --subnet=172.18.0.0/16 docker1
# docker run -d --name pihole -p 53:53/tcp -p 53:53/udp -p 80:80 -e ServerIP=212.237.9.209 --net docker1 --ip 172.18.0.2 diginc/pi-hole:alpine
# docker inspect pihole | grep NetworkMode
            "NetworkMode": "docker1",

But with Ansible's docker_container, I get "NetworkMode": "default", and then I can't access the IP address from another container:

This part I tested and works the same:

- docker_network:
    name: docker1
    ipam_options:
      subnet: 172.18.0.0/16

Now here lies the problem:

- docker_container:
    name: pihole
    image: diginc/pi-hole:alpine
    ports:
      - '53:53/tcp'
      - '53:53/udp'
      - '80:80'
    networks:
      - name: docker1
        ipv4_address: 172.18.0.2
    env:
        ServerIP: '{{ inventory_hostname }}'

Your help will be appreciated!

--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-project+unsubscribe@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/5518d367-3990-4ba1-b62c-c6b41f72c383%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages