We have two apps running in the system, one is from docker and another is directly running on the system, We need to access the system's app inside container app using localhost:8082
API
We are running a node JS
container which is port 5000 on Windows 10
Home using Docker toolbox
, and running an app outside container means directly from the machine which is 8042, We need to access this localhost:8042
API inside the node container, how can We archive it?, using Docker version 19.03.1
Run cmd:
docker container run -p --net=host -it -v `pwd`:/usr/src/app --rm --name server server/windows:v1
Error: Connection refuesed 127.0.0.1:8042
while running docker container.
Complete Error:
(node:80) UnhandledPromiseRejectionWarning: Error: connect ECONNREFUSED 127.0.0.1:8042
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1137:16)
(node:80) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection,
use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:80) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will
terminate the Node.js process with a non-zero exit code.
Dockerfile
FROM node:12
WORKDIR /usr/src/app
COPY package*.json ./
RUN npm install
COPY . .
# Specify port app runs on
EXPOSE 5000
# Run the app
CMD [ "npm", "run", "dev"]