Closed timgeb closed 3 years ago
Hey Tim,
The issue is with the way that DNS resolution works in containers. localhost
in a container means just that container. You would need to specify the name of the postgres container running on your machine for that to work.
You'd have to create a postgres container like this:
docker run --rm --name mypostgrescontainer -p 5432:5432 postgres:alpine
and then connect to it with:
sudo docker run --rm -ti -v /home/tim/grafana/grafana.db:/grafana.db grafana-sqlite-to-postgres /grafana.db "postgres://grafana:grafana@mypostgrescontainer:5432/grafana?sslmode=disable"
Host mode works because it doesn't do any of the container networking segmentation. From a networking perspective, it's just like running another process on your machine directly so localhost
resolves to your machine's IP (rather than a container IP).
Thank you for this tool!
I'm facing an issue when trying to reach the postgres database that is running on the host. I'm not sure if there's something missing in the README or if I misunderstood something.
The README provides the command
which in my case would look like this (
docker
requiressudo
on my system, Ubuntu 18.04.5 LTS):However, the command fails with the following output:
When I add the
--network=host
option to thedocker
command, the database connection is successful.