svix / svix-webhooks

The enterprise-ready webhooks service 🦀
https://www.svix.com
MIT License
2.34k stars 162 forks source link

Connection Timeout Running in Container #706

Closed nkreiger closed 1 year ago

nkreiger commented 1 year ago

Bug Report

docker run -e SVIX_LOG_LEVEL="debug" -e SVIX_CACHE_TYPE="memory" -e SVIX_JWT_SECRET="x" -e DATABASE_URL="postgresql://$USER:$PASSWORD@127.0.0.1:5432/svix" docker.io/svix/svix-server:latest
docker run -e SVIX_LOG_LEVEL="debug" -e SVIX_CACHE_TYPE="memory" -e SVIX_JWT_SECRET="x" -e DATABASE_URL="postgresql://$USER:$PASSWORD@localhost:5432/svix" docker.io/svix/svix-server:latest

Against a database running in k8s, port-forwarded. I was able to confirm connection string with my local DB editor (DataGrip). to the exact connection string. Any ideas what I am doing wrong?

tasn commented 1 year ago

localhost and 127.0.0.1 are both pointing inside the container, you want to point to the host machine.

One easy trick is to find your LAN address and use that. Does that work? A better solution is to use the docker add-hosts to add your local machine inside of the Svix docker and then connect to that.

nkreiger commented 1 year ago

@tasn ah you're right, I forgot it runs inside its own network (long time since I ran a stack not docker-composed), this can be closed, my bad.

tasn commented 1 year ago

No worries! One quick hack that may solve it too: I think there's a way to tell docker to just use the host's network device directly, instead of a private network.

nkreiger commented 1 year ago

@tasn for reference in case someone searches this:

docker run -e SVIX_LOG_LEVEL="debug" --network="host" -e SVIX_CACHE_TYPE="memory" -e SVIX_JWT_SECRET="x" -e DATABASE_URL="postgresql://$USER:$PASSWORD@$DOCKER_INTERNAL_HOST:5432/svix" docker.io/svix/svix-server:latest

where the host is === to host.docker.internal

tasn commented 1 year ago

Awesome, thanks a lot!

St8Ev commented 6 months ago

Я запустил: docker compose up у меня вывод: image Это правильно?