'Docker: could not create IPv6 socket for address "::": Address family not supported by protocol

I'm trying to start a postgres server using docker but it fails as soon as it starts. I believe it is something in the container and not on the host machine but I cannot find a configuration to use ipv4

db_1       | PostgreSQL Database directory appears to contain a database; Skipping initialization
db_1       | 
db_1       | 2022-04-12 20:25:50.331 UTC [1] LOG:  starting PostgreSQL 13.3 (Debian 13.3-1.pgdg100+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 8.3.0-6) 8.3.0, 64-bit
db_1       | 2022-04-12 20:25:50.333 UTC [1] LOG:  listening on IPv4 address "0.0.0.0", port 5432
db_1       | 2022-04-12 20:25:50.334 UTC [1] LOG:  could not create IPv6 socket for address "::": Address family not supported by protocol
db_1       | 2022-04-12 20:25:50.340 UTC [1] LOG:  listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
db_1       | 2022-04-12 20:25:50.349 UTC [26] LOG:  database system was shut down at 2022-04-12 20:22:58 UTC
db_1       | 2022-04-12 20:25:50.354 UTC [1] LOG:  database system is ready to accept connections

This is the compose file

# Use postgres/example user/password credentials
version: '3.1'

services:

  db:
    restart: on-failure
    image: postgres
    environment:
      POSTGRES_PASSWORD: postgres
    ports:
      - 5432:5432
  
  adminer:
    restart: on-failure
    image: adminer
    command: php -S 0.0.0.0:8080 -t /var/www/html
    ports:
      - 8080:8080

I'm using

lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 20.04.4 LTS
Release:    20.04
Codename:   focal


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source