Spotify is now an integration that you can add in the configuration page, have you tried that?
Also, your configuration.yaml, or even better it’s directory, should be mapped in docker so that you can edit it without needing to login to the container.
You can try to put in your public IP as the callback URL and the port, if that doesn’t work, you can also setup some sort of reverse proxy like nginx to handle the calls. In my case, HA is accessible at assistant.MYDOMAIN.com
I have a domain name on hostinger where I replace the DNS by cloudflare ones.
On cloudflare I set my ip address
In my router I redirect 80 and 443 to my server
The reason: The Spotify component uses get_url() without prefere_external , so using the internal IP address, which defaults to the local (docker) IP if not set.