20 lines
1.2 KiB
Markdown
20 lines
1.2 KiB
Markdown
---
|
||
title: 坑:容器↔宿主网络可达性(host.docker.internal / 172.17.0.1 / 0.0.0.0)
|
||
type: experience
|
||
permalink: main/projects/d5a7f581-c442-4554-87b9-ee723b8b0258/坑容器-宿主网络可达性-host.docker.internal-172.17.0.1-0.0.0.0
|
||
stable_id: 6e63a053-fea4-4785-984c-b61fab08810a
|
||
scope: project
|
||
project_id: d5a7f581-c442-4554-87b9-ee723b8b0258
|
||
memory_type: experience
|
||
status: active
|
||
revision: 1
|
||
restored_from_commit: 6a6a895eafcca6052e81a14fca103a42635dd1c2
|
||
created_at: '2026-09-23T15:10:07.905795+00:00'
|
||
updated_at: '2026-09-23T15:10:07.905854+00:00'
|
||
tags:
|
||
- pitfall
|
||
- network
|
||
- docker
|
||
---
|
||
|
||
1) 容器内访问宿主 Metrix:用 host.docker.internal,且 Metrix 后端必须 METRIX_HOST=0.0.0.0(默认 127.0.0.1 容器内不可达)。2) bridge 网络容器访问宿主上另一容器的映射端口:不能用宿主 LAN IP(无 NAT hairpin),要用网桥网关 172.17.0.1(如 pip 源 http://172.17.0.1:18280/simple/)。3) 开发机无法直连线上 18280(iKuai 只映射了部分端口),验证 pypiserver 内容走 Metrix API /api/pypi/packages。4) 本机 PowerShell 的 Invoke-WebRequest 会走系统代理导致连内网 IP 失败,用 curl.exe --noproxy "*"。 |