Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

264
Visualizações
Docker service restart policy - stop old service when new service is really ready

I have tomcat running as docker service in a swarm. When the service starts it loads lots of data into memory, which can take depending on the amount of data between 10 and 30 minutes.

My problem is when I update the service (order:start-first) the old container is stopped before the new container has intialized it'S data and is so not ready to use.

A promising approach seemed to me the health check configuration in my docker-compose:

healthcheck:
      test: ["CMD", "curl", "-f", "http://localhost:8080/areyouready"]
      interval: 10s
      timeout: 10s
      retries: 30

The healthcheck works fine but the old service also shuts down while the test returns 1 (not healthy) for the new service.

I also tried to handle the SIGTERM in my application: The running service gets the sigterm and checks whether it should already stop depending on the state of the new service:

 Runtime.getRuntime().addShutdownHook(new Thread()
        {
            @Override
            public void run()
            {
                // via db access determine the state of the new started containers, but I don't know
                // how to prevent my tomcat from stopping here
            }
        }

Besides that I didn't manage to prevent my tomcat from stopping it just didn't seem to be the right way.

My desired solution would be to configure something like this:

update_config: 
    order: start-first
    a-kind-of-stop-condition: ["CMD", "curl", "-f", "http://localhost:8080/areyouready"]

the condition request should then go to the new created container and if it succeeds the old may be stopped.

It would be great if you could point me into the right direction.

Kind regards, Sebastian

over 4 years ago · Santiago Trujillo
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda