Basic Go application with Postgres.
- Run PostgreSQL database with docker compose:
$ docker-compose up -d
- Get PostgreSQL container IP address:
$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
29192497eff2 adminer "entrypoint.sh docke…" About an hour ago Up 7 minutes 0.0.0.0:8080->8080/tcp, :::8080->8080/tcp go-postgres_adminer_1
796d7e557340 postgres "docker-entrypoint.s…" About an hour ago Up 7 minutes 5432/tcp go-postgres_db_1
$ docker inspect 796d7e557340
- Run Go application with
DATABASE_URL
:
DATABASE_URL="postgres://postgres:[email protected]:5432/postgres" go run main.go