I'm completely new to Docker and had to jump in today. I created a docker-compose.yml file that sets up two containers: one for my Next.js app and the other for my Spring Boot backend. The GET requests are working perfectly fine, but I'm running into trouble with POST requests. Every time I try to make a POST request, I encounter an error: net:::ERR_NAME_NOT_RESOLVED. I have the backend URL http://assessment-backend:8000 configured in my docker-compose.yml. Can anyone help me figure out what's going wrong?
2 Answers
It sounds like you might be dealing with hostname resolution issues. The error you’re seeing suggests that your service can’t find the other service by name. Make sure your containers are correctly connected in the same network, and check that your requests are using the right service names. For example, if you want to reach the backend, it should be something like http://assessment-backend:8000, not an alternative name that doesn't exist. If you can share more of your docker-compose.yml file, that could help us troubleshoot further!
Honestly, when asking for help, it’s important to provide more details. What does your POST request look like? What versions of the apps are you using? Your current situation isn't clear enough for someone to provide a precise answer. Remember, your browser might be trying to access the backend using a DNS name that’s not resolvable outside of Docker's network. Make sure your setup aligns with that.
I appreciate the feedback! I wasn't clear because I was overwhelmed, but you hit the nail on the head.