Docker访问宿主机网络

date
May 16, 2022
slug
tip-docker-access-host-ip
status
Published
summary
小技巧
tags
tip
docker
type
Post
URL

Problem & Summary

    Solution

    Linux

    docker network create -d bridge --subnet 192.168.99.0/24 --gateway 192.168.99.1 localNet
    
    docker exec -it speedtest ping 192.168.99.1
    notion image

    Mac / Windows

    # 对于mac和windows,可以使用
    host.docker.internal
    # 替换127.0.0.1

    Screenshots

    notion image
     

    © Ying Bun 2021 - 2024