Although I have mentioned restart: no in my docker compose file, the container instance comes up with "Always" restart policy

Sreeja Sridhar Ch 110 Reputation points
2023-02-01T13:01:58.31+00:00

I have mentioned the restart property in my docker-compose.yml file as "restart: no" and ran the command "docker compose -f up" from Azure CLI. But when the container is brought up, it has restart policy set as "Always". The container keeps restarting, so I cannot bash into it either to check logs.

P.S: Since I am using docker context, Cannot use docker update command.

services:
  pdi:
    restart: no

User's image

Not Monitored
Not Monitored
Tag not monitored by Microsoft.
42,117 questions
{count} vote

3 answers

Sort by: Most helpful
  1. Andrei Barbu 2,591 Reputation points Microsoft Employee
    2023-02-01T13:10:29.7833333+00:00

    Hello Sreeja,

    By default the restart policy is Always for ACI as per this link. You may wat to set the Restart Policy to Never or OnFailure. You can set it during ACI creation via Portal from Advanced tab or use --restart-policy flag if you create the ACI via CLI.

    More details here about restart policies in ACI.


    I hope this is helpful. If any clarification needed, let me know and I will do my best to answer.

    Please "Accept as Answer" and Upvote if it helped, so that it can help others in the community looking for help on similar topics.

    Thank you!


  2. Ammar-Abdelqader01 1,171 Reputation points Microsoft Employee
    2023-02-01T13:18:46.0533333+00:00

    Hello @Sreeja to change the restart policy on the docker-compose.yaml to none you have to use "Never" as below:

    YAML
    
    Copy
    services:
      pdi:
        restart: Never
    
    please cehck this document to use restart policies : 
    
    
    

  3. Sreeja Sridhar Ch 110 Reputation points
    2023-02-02T12:48:37.69+00:00

    Used docker compose swarm mode in my docker compose and ran with compatibility attribute and it worked!

    Now i am unable to exec into the container as it is terminated. Is there a workaround for bash into terminated containers.

    https://stackoverflow.com/questions/42216017/docker-compose-restart-policy

        deploy:
          restart_policy:
            condition: on-failure
            delay: 60s
            max_attempts: 3
            window: 120s
    
    docker-compose -f docker-compose.yml --compatibility up
    
    
    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.