How to access host port from docker container

前端 未结 14 1544
南旧
南旧 2020-11-22 03:41

I have a docker container running jenkins. As part of the build process, I need to access a web server that is run locally on the host machine. Is there a way the host web s

14条回答
  •  情深已故
    2020-11-22 03:49

    For linux systems, you can – starting from major version 20.04 of the docker engine – now also communicate with the host via host.docker.internal. This won't work automatically, but you need to provide the following run flag:

    --add-host=host.docker.internal:host-gateway
    

    See

    • https://github.com/moby/moby/pull/40007#issuecomment-578729356
    • https://github.com/docker/for-linux/issues/264#issuecomment-598864064

提交回复
热议问题