Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

docker-compose.yml: Why does restart "no" have to have quotation marks?

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.

like image 649
chloesoe Avatar asked Sep 15 '17 06:09

chloesoe


People also ask

What does restart always do in docker compose?

What does restart always do in Docker compose? Restarts all stopped and running services, or the specified services only. If you make changes to your compose.

Does docker compose restart?

Like the restart Docker command, Docker Compose includes the restart property to restart containers automatically.

What is the default restart policy in docker?

This is the default policy for all containers created with docker run . always – Docker will ensure the container is always running. If the container stops, it will be immediately restarted.

What is restart unless stopped docker?

This means that with the unless-stopped restart policy, if the container was running before the reboot, the container would be restarted once the system restarted. When an application within a Docker container exits, that container will be also halted.


1 Answers

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

like image 149
Tarun Lalwani Avatar answered Oct 07 '22 12:10

Tarun Lalwani