[英]I can not access by public IP to my Docker Node.js container
我有一個 Docker Node.js 容器監聽端口 4757 和 NET 庫,使用我的公共 IP。
server listening on {"address":"144.xxx.xxx.66","family":"IPv4","port":4757}
當我從我的計算機訪問時,我沒有問題,但如果我嘗試訪問我的移動設備或其他設備,則連接被拒絕(ERR_ADDRESS_UNREACHABLE)。
該應用程序在其他筆記本電腦上由 docker-composer 正常工作,問題出在我的新筆記本電腦上。 這是我的 local.yml
version: '3'
volumes:
local_postgres_data: {}
local_postgres_data_backups: {}
services:
django: &django
build:
context: .
dockerfile: ./compose/local/django/Dockerfile
image: hegeo_local_django
depends_on:
- postgres
volumes:
.:/app
env_file:
- ./.envs/.local/.django
- ./.envs/.local/.postgres
ports:
- "8000:8000"
command: /start
networks:
default:
ipv4_address: 144.xxx.xxx.3
node:
build:
context: .
dockerfile: ./compose/production/nodejs/Dockerfile
image: hegeo_node
depends_on:
- postgres
links:
- postgres
ports:
- "4757:4757"
networks:
default:
ipv4_address: 144.xxx.xxx.66
postgres:
build:
context: .
dockerfile: ./compose/production/postgres/Dockerfile
image: hegeo_production_postgres
volumes:
- local_postgres_data:/var/lib/postgresql/data
- local_postgres_data_backups:/backups
env_file:
- ./.envs/.local/.postgres
networks:
default:
ipv4_address: 144.xxx.xxx.4
networks:
default:
driver: bridge
driver_opts:
com.docker.network.enable_ipv6: "false"
ipam:
driver: default
config:
- subnet: 144.xxx.xxx.0/24
我認為我必須使用“docker run”但也不能工作。 Docker - 使 docker 容器使用我的公共 ip
編輯:關鍵是,我使用了網絡“驅動程序”,因為我從地理定位設備接收跟蹤,我需要使用 Node.js 解析此跟蹤並將其發送到 Django。 如果我沒有設置網絡並將 ipv4_address 分配給 Django,則 Django 和 Node.js 之間的連接不起作用。
您提到您已打開端口並將其從路由器轉發到筆記本電腦。 您的docker Z6EEDC03A68A68A699999993C763E674F2D7C42FZ不需要了解ZA12A3079E.14CED4CED4CED4CED4CED4CED4CED4CABER2B.46EBAB2B82B81B8ANAZ,您應該是您,這是您的ZA12B21F21F21F21F21F21F21F21F21F21F21F21F21F21F21F21F21F21F21F21F21F21F21F21F21F21F21F21F21F21F21F21F21F21F21F21F21F21FAB21F21F21FAB21F.
Internet > (public IP) Router (NAT to Local Docker host machine IP) > Docker host laptop (with firewall off, or port open) > docker engine (port is mapped from host to container) > your Node.js script listening to on the port.
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.