How to access host port from docker container

前端 未结 14 1739
南旧
南旧 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:57

    We found that a simpler solution to all this networking junk is to just use the domain socket for the service. If you're trying to connect to the host anyway, just mount the socket as a volume, and you're on your way. For postgresql, this was as simple as:

    docker run -v /var/run/postgresql:/var/run/postgresql
    

    Then we just set up our database connection to use the socket instead of network. Literally that easy.

提交回复
热议问题