19

In the docker docs for docker-compose (https://docs.docker.com/compose/compose-file/#restart) this restart options are given:

restart: "no"
restart: always
restart: on-failure
restart: unless-stopped

I'm just wondering, why the "no" has to be in quotation marks and the other options not? The docker-compose can't start with no without quotation marks.

1 Answer 1

29

The reason is values yes and no are evaluated as true or false. That is why you need to use double quotes so that it is interpreted as string

Please see http://www.yaml.org/refcard.html

1
  • 8
    Strange to use it for this setting then. Seems like "never" would have been a better choice. Or just allow "no" as a boolean since it does seem to mean "false" here anyway. Your answer is correct, just commenting that this feels like sloppy design.
    – DougW
    Apr 8, 2020 at 21:05

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.