I have a container running a Nuxt.js (Vue.js) app, defined by docker_composes.yml
:
version: '3' services: vue: build: . image: registry.gitlab.com/something/app:${TAG} environment: - apiPath="http://localhost:5000/" - filePath="http://localhost:3000/" ports: - "${EXPOSED_PORT:-80}:${NUXT_PORT:-3000}" restart: always
The app is a frontend. I am running the backend on localhost, on port 5000
. When the containerized app tries to connect to http://localhost:5000/
it fails.
What are my options? I don't want to put the backend into the docker_composes.yml
and connect them by link. If it's the only option though, I will.
localhost
in your docker-compose.yaml
file refers to container.
In order to access your local machine use host.docker.internal
instead of localhost
.
You could try using
network_mode: "host"
https://docs.docker.com/compose/compose-file/#network_mode
If you're on Windows or Mac you should be able to use:
docker.for.win.localhost
or
docker.for.mac.localhost
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With