I wanted learn more about using docker and containers for setting up a good development environment.

My solution right now consists of a front end built with Nextjs and an ASPNET core backend. Each of the apps have their own docker compose files which I can use to get both up and running and go against live services.

Most of the time though, I want to be able to get both running and talking with each other. In that case, I run a multi-container docker app with both the web and api. Since my web app had server side code calling the api, I realized that I couldn’t use localhost:port as my api url. I found https://stackoverflow.com/questions/37063822/econnrefused-nodejs-with-express-inside-docker-container/40091406#40091406 and basically the fix was to:

  1. run docker network ls to find the network name of my app

2. run docker network inspect web_default to find the gateway address so i could use that plus the exposed port as the api address. So in this case, instead of https://localhost:8080, i would use https://192.168.224.1:8080

Leave a comment