# Assigning IPv6 Port Mapping in docker\_container leads to replacement with DEFAULT\_IP\_REPLACEMENT\_STRING

**URL:** <https://forum.ansible.com/t/assigning-ipv6-port-mapping-in-docker-container-leads-to-replacement-with-default-ip-replacement-string/44913>\
**Category:** Get Help\
**Tags:** docker\
**Created:** [November 30, 2025, 3:27pm UTC](https://forum.ansible.com/t/assigning-ipv6-port-mapping-in-docker-container-leads-to-replacement-with-default-ip-replacement-string/44913 "2025-11-30T15:27:31Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![simonh1005](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/simonh1005/32/9884_2.png) [@simonh1005](https://forum.ansible.com/u/simonh1005)\
**Post date:** [November 30, 2025, 3:27pm UTC](https://forum.ansible.com/t/assigning-ipv6-port-mapping-in-docker-container-leads-to-replacement-with-default-ip-replacement-string/44913/1 "2025-11-30T15:27:31Z")

</div>

Dear Community,  
**Context of my situation:**  
I am trying to deploy a DNS-server as docker container using ansible and the docker\_container module. The Setup is running since years, but now I am trying to extend it by IPv6. Therefore I configured an IPV6 ULA on the docker host and enabled ipv6 in the docker deamon. Now I am trying to publish the ports of my container not only to IPv4, but also to IPv6. As the container is also used as DNS server by some other containers, I do not use the bridge network, but several custom networks. The port mappings are there as external clients are supposed to use the ports directly, without going through the docker networks.

**The Problem**  
my YAML task for setting up the docker container looks as follows:

```auto
- name: ensure pi-hole is up
  tags: pihole
  docker_container:
    name: pihole
    image: pihole/pihole:latest
    pull: "{{ update_docker_image }}"
    ports:
      - "53:53"
      - "53:53/udp"
      - "[fd00:0:0:50::50]:53:53"
      - "[fd00:0:0:50::50]:53:53/udp"
    networks_cli_compatible: yes
    networks:
      - name: dns_network
      - name: monitoring_network
        ipv4_address: 172.20.0.100
      - name: traefik_network
...

```

I also already tried some simplified IPv6 like `[::1]:53:53` for testing purposes, but the result stays the same.

**Expected Behavior**  
Ansible deploying a docker container that listens to port 53 on IPv4 and IPv6

**Actual Behavior**  
I am getting the following error:

```auto
[ERROR]: Task failed: Module failed: Error creating container: 400 Client Error for http+docker://localhost/v1.52/containers/create?name=pihole: Bad Request ("invalid JSON: ParseAddr("[[DEFAULT_IP:iewahhaeB4Sae6Aen8IeShairoh4zeph7xaekoh8Geingunaesaeweiy3ooleiwi]]"): each colon-separated field must have at least one digit (at "[[DEFAULT_IP:iewahhaeB4Sae6Aen8IeShairoh4zeph7xaekoh8Geingunaesaeweiy3ooleiwi]]")")

```

**What I already checked**  
Did some googling but could not find anything. Furthermore I had a quick look at the Github repo of the docker community and found out that the string from my error message is defined there as hardcoded [\_DEFAULT\_IP\_REPLACEMENT\_STRING](https://github.com/ansible-collections/community.docker/blob/faa7dee456bca5b9f72e64e3c84def65e7dbbd39/plugins/module_utils/_module_container/base.py#L53).  
Following the usage of [this function](https://github.com/ansible-collections/community.docker/blob/faa7dee456bca5b9f72e64e3c84def65e7dbbd39/plugins/module_utils/_module_container/base.py#L961), I found this method which is replacing the IP with the \_DEFAULT\_IP\_REPLACEMENT\_STRING in some cases.

---

<div class="post-metadata">

**Author:** ![felixfontein](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/felixfontein/32/7530_2.png) [@felixfontein](https://forum.ansible.com/u/felixfontein)\
**Post date:** [November 30, 2025, 4:00pm UTC](https://forum.ansible.com/t/assigning-ipv6-port-mapping-in-docker-container-leads-to-replacement-with-default-ip-replacement-string/44913/2 "2025-11-30T16:00:01Z")

</div>

Check out the 5.0.3 release of community.docker, it has a bugfix for this: [Release 5.0.3 · ansible-collections/community.docker · GitHub](https://github.com/ansible-collections/community.docker/releases/tag/5.0.3)

---

<div class="post-metadata">

**Author:** ![simonh1005](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/simonh1005/32/9884_2.png) [@simonh1005](https://forum.ansible.com/u/simonh1005)\
**Post date:** [November 30, 2025, 4:09pm UTC](https://forum.ansible.com/t/assigning-ipv6-port-mapping-in-docker-container-leads-to-replacement-with-default-ip-replacement-string/44913/3 "2025-11-30T16:09:29Z")

</div>

Hi Felix,  
thanks for the hint. It seems that updating indeed fixed the issue.

Kind Regards,  
Simon

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/ansible/original/1X/1882d9a01da5d8996a862359b0913cc568a39b84.svg) [@system](https://forum.ansible.com/u/system)\
**Post date:** [December 30, 2025, 4:09pm UTC](https://forum.ansible.com/t/assigning-ipv6-port-mapping-in-docker-container-leads-to-replacement-with-default-ip-replacement-string/44913/4 "2025-12-30T16:09:38Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
