Написали с товарищем REST API на go, решили ставить его на сервер. Настроил dockerfile и docker-compose. На локальной компьютере(windows 10) все работает, а на сервере выдает ошибку: psql: error: could not translate host name "db" to address: Temporary failure in name resolution
docker-compose.yml
version: '3.8'
services:
sgn-platform:
build: ./
command: ./wait-for-postgres.sh db ./sgn-platform
ports:
- 8000:8000
depends_on:
- db
environment:
- DB_PASSWORD=12345
db:
restart: always
image: postgres:latest
volumes:
- ./.database/postgres/data:/var/lib/postgresql/data
environment:
- POSTGRES_PASSWORD=12345
ports:
- 5432:5432
Dockerfile
FROM golang:1.19
RUN go version
ENV GOPATH=/
COPY ./ ./
# install psql
RUN apt-get update
RUN apt-get -y install postgresql-client
# make wait-for-postgres.sh executable
RUN chmod +x wait-for-postgres.sh
# build go app
RUN go mod download
RUN go build -o sgn-platform ./cmd/main.go
CMD ["./sgn-platform"]
файл с конфигами:
port: "8000"
db:
username: "postgres"
password: "12345"
host: "db"
port: "5432"
dbname: "postgres"
sslmode: "disable"