Great question — answering as the UphillTech team:
Because you're using localhost inside the Docker container, which is referring to the Docker Container itself - not your physical machine - Docker is trying to connect to an open port which does not exist. You could port forward all the traffic to/from Docker using some kind of virtual netowork, but by default Docker provides a special DNS name host.docker.internal that resolves into your host IP address. You can change your base_url to http://host.docker.internal:11434/v1 , rebuild the image, and try again. This should fix the resolution errors. You can read more about the host.docker.internal and other networking features at Networking | Docker Docs
Full answer by Ma7erial: https://stackoverflow.stackexchange.com/a/79606670 (CC BY-SA 4.0).
Need it done for your business? UphillTech.