There are a few details that I think would improve your post.
I needed to connect to Postgresql from a different container that runs the code. To do so I needed the IP of the postgres docker, you can get that using the following command
docker inspect [container]
The IP Address can be found in the output looking something like this "IPAddress": "172.17.0.3"
With that I could now create an environment variable for the connection URL
DATABASE_URL=postgres://postgres:docker@172.17.0.3:5432/world?sslmode=disable go run main.go
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
There are a few details that I think would improve your post.
I needed to connect to Postgresql from a different container that runs the code. To do so I needed the IP of the postgres docker, you can get that using the following command
docker inspect [container]
The IP Address can be found in the output looking something like this "IPAddress": "172.17.0.3"
With that I could now create an environment variable for the connection URL
DATABASE_URL=postgres://postgres:docker@172.17.0.3:5432/world?sslmode=disable go run main.go