skip to Main Content

I’m running 20 container in my docker, i have some issue if all run at same time, after 5 containers run the rest will be show too many request in each the logs.

how to setup delay 1 minute or more from one container to next container, so next container will run 1 minute more after first container success run.

atm i just do by manual reset the rest container by manual

is it possible do this in portainer?

thanks.

2

Answers


  1. You can use docker compose and healthchecks for this purposes:

    For example:

    version: '3.8'
    
    services:
      service1:
        image: <your_image1>
        container_name: container1
        healthcheck:
          test: ["CMD", "curl", "-f", "http://localhost:80"]
          interval: 30s
          timeout: 10s
          retries: 3
          start_period: 30s
    
      service2:
        image: <your_image2>
        container_name: container2
        depends_on:
          service1:
            condition: service_healthy
        command: sh -c "sleep 60"
    
      service3:
        image: <your_image3>
        container_name: container3
        depends_on:
          service2:
            condition: service_healthy
        command: sh -c "sleep 60"
    
    Login or Signup to reply.
  2. What is the issue that you face while running all the containers at same time, In my opinion it would be dependency of one container over the other.

    To answer your question you may use the docker compose as below to add delays

    
    version: '3'
    services:
      container1:
        image: your-image-1
        command: bash -c "sleep 0 && your-original-command-1"
    
      container2:
        image: your-image-2
        depends_on:
          - container1
        command: bash -c "sleep 60 && your-original-command-2"
    
      container3:
        image: your-image-3
        depends_on:
          - container2
        command: bash -c "sleep 60 && your-original-command-3"
    
      container4:
        image: your-image-4
        depends_on:
          - container3
        command: bash -c "sleep 60 && your-original-command-4"
    
      container5:
        image: your-image-5
        depends_on:
          - container4
        command: bash -c "sleep 60 && your-original-command-5"
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search