A
A
Alexander Karpov2020-07-30 13:22:54
Docker
Alexander Karpov, 2020-07-30 13:22:54

Is it possible to declare a service container for Docker that will listen on a specific port only if no other containers are listening on it?

The task is next.
I really need to elegantly make a "service being served" page and return it in cases where the container with the main service is stopped. At the same time, I would like not to have to start and stop an additional container for this.

For example
"Container A" is nginx serving the application.
"Container B" - nginx, which stupidly returns "maintenancepage.html".

I would like (without kubernetes) that "Container B" listens to port 443 and 80 of the machine in the event that "Container A" does not listen to these ports (i.e. if "Container A" is down).

For some reason I feel like it should be possible. I searched the dock - I did not find it, I decided to ask the community.

Thanks in advance!

PS. Probably it is necessary to dissolve everything on nginx. For example, using the same `upstream` https://nginx.org/ru/docs/http/ngx_http_upstream_m...

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry, 2020-07-30
@Inkognitoss

The simplest thing is to have a front-end Nginx that will process the 503 code and throw it at the appropriate stub.
banal

error_page 500 502 503 504 /sorry.html;
        location = /sorry.html {
            root /var/www/maintenance/;
        }

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question