Docker disable IPv6 for a network

So I have compose file like this that bootstraps all the services required

volumes:
  db-local-prc:

networks:
  prc-local-network:
    external: true

services:
  app:
    ...
    restart: always
    ports:
      - "3000:3000"
    depends_on:
      postgres:
        condition: service_healthy
    networks:
      - prc-local-network
  postgres:
    image: "postgres:15-alpine"
    container_name: prc-postgres-local
    restart: always
    ports:
      - "5432:5432"
    healthcheck:
      test: ["CMD", "pg_isready", "-U", "postgres"]
      interval: 10s
      timeout: 5s
      retries: 5
    volumes:
      - db-local-prc:/var/lib/postgresql/data
    networks:
      - prc-local-network
    env_file:
      - ../envs/.env.local
  redis:
    image: redis:6.2-alpine
    container_name: prc-redis-local
    restart: always
    ports:
      - "6379:6379"
    networks:
      - prc-local-network
    env_file:
      - ../envs/.env.local
  gotenberg:
    image: thecodingmachine/gotenberg:8
    container_name: gotenberg-local
    ports:
      - "3200:3000"
    restart: always
    networks:
      - prc-local-network

  mailhog:
    image: dockage/mailcatcher
    container_name: prc-mailcatcher-local
    restart: always
    ports:
      - "1025:1025" # SMTP Server
      - "1080:1080" # Web UI
    networks:
      - prc-local-network

The app container is a single monolith NestJS application, now the problem is that we use a service for verifying email the things is that the service only works over IPv4 I guess, but does not works on IPv6, I verified it by the running the following inside the container:

# ping -6 api.verifalia.com
PING api.verifalia.com (2a01:4f8:222:1ba6::2): 56 data bytes
ping: sendto: Network unreachable

# ping -4 api.verifalia.com
PING api.verifalia.com (5.9.101.113): 56 data bytes
64 bytes from 5.9.101.113: seq=0 ttl=53 time=277.029 ms
64 bytes from 5.9.101.113: seq=1 ttl=53 time=276.794 ms
^C
--- api.verifalia.com ping statistics ---
2 packets transmitted, 2 packets received, 0% packet loss
round-trip min/avg/max = 276.794/276.911/277.029 ms

Now I wanted to know how should I proceed with this, like should I disable IPv6 on docker, if yes then would it disrupt any other services that are used. Also wanted to know is there a way to only disable IPv6 on a particular network.

Also please help me out on how to disable IPv6. Thank you.

That command only verified that IPv6 is not supported in your container, not that the service doesn’t work on IPv6. So you already have IPv6 disabled which is the default setting in the daemon and also in Docker networks

docker network create | Docker Docs .

Why do you think that IPv6 is the problem?.

The service provider has the asked me to perform these commands. Although they have not mentioned that the service only supports IPv6, but pinging with the -4 flag is successful. Same thing in node js by defining the IP family I can use the service.

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