J
J
JohnDaniels2020-03-15 14:18:16
Node.js
JohnDaniels, 2020-03-15 14:18:16

How to set up Nuxt (SSR) + docker-compose correctly?

There is a container with a nuxt application, and a container with an api backend for this application, all running locally with a url like site.local.

from the browser, requests to api.site.local pass without errors, but I need to send a request to the api container from the nuxt container, and this is where the problems begin.

axios returns an error:

Error: getaddrinfo ENOTFOUND api.site.local api.site.local:443
    at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:56:26)
  errno: 'ENOTFOUND',
  code: 'ENOTFOUND',
  syscall: 'getaddrinfo',
  hostname: 'api.site.local',
  host: 'api.site.local'

That is, as far as I understand, dns does not know the ip for api.site.local. Is this the correct guess?

I tried adding the ip of the api container using dns.setServers(), it didn't change anything.

What is the right thing to do in such a situation?
How will this thing behave on a server with real urls?

PS I use laradock

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
mureevms, 2020-03-15
@JohnDaniels

If the container is started with the name of this container, such as this,
docker run --name my-redis -d redis
then the DNS name of this container will be my-redisand the host will be resolved from other containers.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question