cannot access postgres running in docker via pg_isready or pgAdmin

I have a simple postgres running in docker. Everything works ok. I also can access it via:

docker exec -it db bash and there using psql.
But both pg_isready and pgAdmin fail to access it via localhost at port 5432

version: "3"
services:
  db:
    image: postgres
    environment:
      POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
      POSTGRES_USER: ${POSTGRES_USER}
      POSTGRES_DB: ${POSTGRES_DB}
    ports:
      - "5432:5432"
    volumes:
      - db-data:/var/lib/postgresql/data
    networks:
      frontend:
        aliases:
          - db

That’s how the container status look like:

CONTAINER ID        IMAGE                COMMAND                  CREATED             STATUS                    PORTS                         NAMES
9295d519be2s        postgres             "docker-entrypoint.s…"   15 minutes ago      Up 15 minutes             0.0.0.0:5432->5432/tcp        ebot_db_1

What is wrong?

Source: StackOverflow