How can remote clients access the docker container?

  docker, question

if inscribe

First of all, I iptables -F cleared all the rules

Then I use itexpress-generatorI created a project test and entered it to create a Dockerfile. In order to facilitate my direct NPM installation, I installed all the required packages.

express test
 cd test
 npm install

Then I put everything directly into the container without installing it again …

from node:latest
 workdir /app
 add . /app
 expose 3000
 cmd npm start

After that, I built my own image and ran it.

docker build -t test0
 docker container run -d -p3000:3000 test0
 # 5380
 docker logs 5380
 # test@0.0.1 start /app
 # node ./bin/www
 docker container ls
 # 5380...     test0     "bin/sh -c..."          ...    0.0.0.0:3000:3000/tcp

I had a local visit by curl myself. No problem.

curl http://172.17.0.2:3000
 # <!  DOCTYPE  ....
 curl http://192.168.2.2:3000
 # <!  DOCTYPE  ....

Supposedly there should be no problem to run …

But I can’t access it when I use other machines on the same LAN (such as 2.5 or 2.7), and I don’t have any access information when I check with docker logs ………….

Before using docker, I tested other machines on npm start. Direct access is no problem. I don’t understand why this is happening … Help!

Docker

ip a

1: lo: <LOOPBACK  .....
 4: eth0@if5: <BROADCAST, MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default
 
 link/ether 02:42:ac:11:00:02    brd ff:ff:ff:ff:ff:ff link-netnsid 0
 inet 172.17.0.2/16 brd 172.17.255.255 scope global eth0
 valid_lft forever preferred_lft forever

ip r

default via 172.17.0.1 dev eth0
 172.17.0.0/16 dev docker0 proto kernel scope link src 172.17.0.1 linkdown
 192.168.2.0/24 dev eno1 proto kernel scope link src 192.168.2.115
 192.168.2.254 dev eno1 proto shcp scope link src 192.168.2.115 metric 100

docker container ls

7c... mariadb "docker-entrypoint.s..." 12 days ago up 6 minutes 0.0.0.0:3306->3306/tcp

Systems outside Docker

ip a

Eno1 is directly connected to 192.168.2.0, logically isolated from the external network, and automatically obtains the IP address through DHCP (not fixed)
 
 docker0: <BROADCAST, MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default
 
 link/ether 02:42:ac:11:87:74    brd ff:ff:ff:ff:ff:ff link-netnsid 0
 inet 172.17.0.1/16 brd 172.17.255.255 scope global docker0
 valid_lft forever preferred_lft forever
 inet 6 ................ scope link
 valid_lft forever preferred_lft forever

ip r

default via 192.168.2.254 dev eno1 proto dhcp src 192.168.2.127 metric 100
 172.17.0.0/16 dev docker0 proto kernel scope link src 172.17.0.1
 192.168.2.0/24 dev eno1 proto kernel scope link src 192.168.2.115
 192.168.2.254 dev eno1 proto dhcp scope link src 192.168.2.127 metric 100

Npm install in dockerfile