'Node.js app in a docker container not reachable over Internet "Connection refused" [duplicate]
I am struggling for a quite some time making a node.js app to be accessible over Internet. The docker container is running on a port 9000. The host machine is an Oracle Linux virtual machine one, on the Oracle Cloud. I have enabled the port 9000 there.
In the container I run the node.js app with:
sh-4.2# node index.js
Starting application
Initializing database module
libDir = /usr/lib/oracle/19.3/client64/lib
Initializing web server module
Web server listening on Host:0.0.0.0, Port:9000
Check the docker container process from within the Oracle Linux host: docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
8504964aa23c 227d64c853db/domaevid-server "sh" About a minute ago Up About a minute 9000/tcp mystifying_babbage
And testing the connection on the host is giving back the error:
[opc@instance-20210318-1902 ~]$ curl http://public.ip:9000/api/home
curl: (7) Failed connect to public.ip:9000; Connection refused
The content of the Dockerfile:
FROM oraclelinux:7-slim
WORKDIR /usr/src/app
COPY package*.json ./
RUN yum -y install oracle-release-el7 && \
yum -y install oracle-instantclient19.3-basiclite && \
yum -y install oracle-nodejs-release-el7 && \
yum-config-manager --disable ol7_developer_EPEL && \
yum install vim-enhanced -y && \
yum -y install nodejs && \
npm install && \
rm -rf /var/cache/yum
RUN echo "export xxx" >> ~/.bashrc && \
echo "export xxx" >> ~/.bashrc && \
echo "export xxx" >> ~/.bashrc && \
echo "export xxx" >> ~/.bashrc && \
echo "export xxx" >> ~/.bashrc
RUN source ~/.bashrc
COPY /_docker/ORACLE/NETWORK/ADMIN/* /usr/lib/oracle/19.3/client64/lib/network/admin
COPY . .
EXPOSE 9000
CMD [ "node", "index.js" ]
What else should be done so the node.js app is reachable over Internet?
Kind regards, Dime
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
