Can (or should) 2 docker containers interact with each other via localhost?

后端 未结 3 1905
礼貌的吻别
礼貌的吻别 2021-02-20 06:28

We\'re dockerizing our micro services app, and I ran into some discovery issues.

The app is configured as follows:

When the a service is started in \'non-local\'

3条回答
  •  夕颜
    夕颜 (楼主)
    2021-02-20 06:56

    If changing the hard-coded addresses is not an option for now, perhaps you could modify the startup scripts of your containers to forward forward ports in each local container to the required services in other machines.

    This would create some complications though, because you would have to setup ssh in each of your containers, and manage the corresponding keys.

    Come to think of it, if encryption is not an issue, ssh is not necessary. Using socat or redir would probably be enough.

    socat TCP4-LISTEN:61001,fork TCP4:othercontainer:61001
    

提交回复
热议问题