Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

258
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!