Mailgun API works fine locally, but when running in Docker, I encounter a fetch error. Environment variables are set correctly, and the Node.js code seems to be causing the problem.
I experienced a similar issue when transitioning my Mailgun API integration to Docker. In my case, the problem turned out to be related to the network configuration within the container. I had to ensure that the container’s DNS settings were properly configured to resolve Mailgun’s endpoints and that there were no restrictions with the host firewall limiting access. Also, double-checking that the environment variables were correctly passed to Docker helped me isolate the issue. I recommend testing the connectivity from within the container using tools such as curl to confirm that external calls are working as expected.
The issue might stem from differences in the environment between your local development and the Docker container. I faced a similar problem where the Mailgun API worked locally but failed in production. In my case, the problem was that the Node environment inside the container was not appropriately picking up updated CA certificates and network configurations. Updating the base image and ensuring that the certificates used by Node.js were current resolved the problem. Additionally, I verified that the API keys and configurations were correctly passed through Docker. Testing connectivity from inside the container using commands like curl helped pinpoint the issue.
maybe try checkin out the container’s dns bindings - had an issue once that was caused by a misconfigured dns, which lead to Mailgun endpoint errors. also double check your firewall & network bridge settings, sometimes they can block external calls.
I encountered a similar issue recently when integrating Mailgun API into my Dockerized environment. The problem was a mix of subtle configuration mismatches between local and container setups. I discovered that the way environment variables were parsed inside the container was slightly different due to the shell used in the Docker image. Logging out the variables helped me confirm that the API keys were read correctly, and then it became clear that upgrading the base image and making sure the proper certificate bundles were in place resolved the connectivity fetch errors.