背景

最近在win10上面折腾docker, 由于机器没有分配固定的IP地址,每次重启之后IP地址都会变化,每次调试都需要改配置,非常麻烦 :(

 

解决

查看本机hosts文件 (C:\Windows\System32\drivers\etc\hosts),发现在安装 docker desktop后, docker已经为配置了默认的子网和gatewa,具体如下:

# Added by Docker Desktop
139.24.227.29 host.docker.internal
139.24.227.29 gateway.docker.internal
# To allow the same kube context to work on the host and the container:
127.0.0.1 kubernetes.docker.internal
# End of section

 

可以看到,139.24.227.29 的 IP 地址已经被docker 所使用,因此,我们就可以使用这个IP作为固定的IP配置,供docker continer 之间通信使用。 

本机 docker container 之外的app, 可以使用 127.0.0.1

 

(完)

相关文章:

  • 2021-08-31
  • 2021-09-04
  • 2022-02-09
  • 2022-12-23
  • 2021-10-19
  • 2021-06-05
  • 2022-12-23
  • 2022-03-03
猜你喜欢
  • 2021-11-10
  • 2021-06-26
  • 2022-02-03
相关资源
相似解决方案