How to create a bidirectional link between containers?

前端 未结 5 1248
梦如初夏
梦如初夏 2020-11-30 01:00

I have to link two containers so they can see each other. Of course the following...

docker run -i -t --name container1 --link container2:container2 ubuntu:t         


        
5条回答
  •  天涯浪人
    2020-11-30 01:35

    Since there is no bidirectional link I solved this issue with the --net argument. That way they are using the same network stack and can therefore access each other over the loopback device (localhost).

    docker run -d --name web me/myserver
    docker run -d --name selenium --net container:web me/myotherserver
    

    So I can access from web the selenium server (port 4444) and my selenium server can access my web server (port 80).

提交回复
热议问题