How do I set up linkage between Docker containers so that restarting won't break it?

前端 未结 11 2226
隐瞒了意图╮
隐瞒了意图╮ 2020-12-02 05:40

I have a few Docker containers running like:

  • Nginx
  • Web app 1
  • Web app 2
  • PostgreSQL

Since Nginx needs to connect to the

11条回答
  •  北海茫月
    2020-12-02 06:20

    with OpenSVC approach, you can workaround by :

    • use a service with its own ip address/dns name (the one your end users will connect to)
    • tell docker to expose ports to this specific ip address ("--ip" docker option)
    • configure your apps to connect to the service ip address

    each time you replace a container, you are sure that it will connect to the correct ip address.

    Tutorial here => Docker Multi Containers with OpenSVC

    don't miss the "complex orchestration" part at the end of tuto, which can help you start/stop containers in the correct order (1 postgresql subset + 1 webapp subset + 1 nginx subset)

    the main drawback is that you expose webapp and PostgreSQL ports to public address, and actually only the nginx tcp port need to be exposed in public.

提交回复
热议问题