error: dial tcp [::1]:5432: connect: connection refused при миграции

Не могу сделать миграцию базы данных.

Пишет ошибку: error: dial tcp [::1]:5432: connect: connection refused

Пробовал ставить разные драйвера, читал документацию по Докеру но решение проблемы не нашел. Не понимаю(

Dockerfile

FROM golang:latest
WORKDIR /handmadeBot/app
COPY . .

RUN go get github.com/spf13/viper
RUN go get github.com/looplab/fsm
RUN go get github.com/go-telegram-bot-api/telegram-bot-api/v5
RUN go get github.com/golang-migrate/migrate/v4

RUN apt install curl
RUN curl -s https://packagecloud.io/install/repositories/golang-migrate/migrate/script.deb.sh | bash
RUN apt-get update
RUN apt-get install migrate

RUN make migrateup
# migrate -path db/migration -database "postgresql://main:123@localhost:5432/handmade?sslmode=disable" -verbose up

CMD ["go", "run", "main.go"]

docker-compose.yml

networks:
  mynet:
    driver: bridge

services:
  bot:
    container_name: handmadeBot
    build: .
    ports:
      - "8080:8080"
    networks:
      - mynet
    depends_on:
      db:
        condition: service_healthy
  db:
    image: postgres:alpine
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U postgres"]
      interval: 25s
      timeout: 25s
      retries: 25
    ports:
      - "5431:5432"
    environment:
      POSTGRES_USER: root
      POSTGRES_PASSWORD: secret
      POSTGRES_DB: handmade
    networks:
      - mynet
    volumes:
      - ./db/init/:/docker-entrypoint-initdb.d/
    restart: unless-stopped

Ответы (0 шт):