goose is the migration tool that helps me to run all the *sql files and run up queries within database. I want to automate migrations(create tables and stuff) using this tool within the docker container on my api service. The problem is when docker runs command "goose run" it gets an error -goose run: dial tcp: lookup db on 192.168.63.6:53: no such host.
docker-compose
services:
db:
build: ./db
volumes:
- ./db/pgdata:/pgdata
image: postgres
ports:
- "5432"
restart: always
environment:
- POSTGRES_USER=user
- POSTGRES_DB=dbname
- POSTGRES_PASSWORD=123
- PGDATA=/pgdata
api:
build:
context: ./api
restart: always
volumes:
- ./api:/go/src/github.com/gitlees/todoapp/api
ports:
- "5000:8080"
links:
- "db"
Api Dockerfile
RUN go get -u github.com/pressly/goose/cmd/goose
RUN goose postgres "host=db user=user dbname=dbname sslmode=disable password=123" up