appexample/app:1.4.2
Runs the image example/app:1.4.2.
Limits memory to 512m. The container is killed if it exceeds this.
Docker Compose check · low
Without a restart policy Docker uses "no": a container that crashes, or that was running when the host or Docker daemon restarted, stays stopped until someone starts it. The explainer flags services with neither restart nor deploy.restart_policy as low. For long-running services, restart: unless-stopped is a common default.
$ explain docker-compose.yml ! app has no restart policy line 2 fix: see below $
What the free Docker Compose explainer reports on the risky example below.
Crashes happen: an out-of-memory kill, an unhandled error, a dependency that was briefly unavailable. Without a policy, one such event leaves the service down until it is noticed.
After a host reboot, Docker brings back containers whose policy says to, and leaves the others stopped.
The policy is also part of what the file documents: a reader can see which services are meant to stay up.
services:
app:
image: example/app:1.4.2
mem_limit: 512m
services:
app:
image: example/app:1.4.2
restart: unless-stopped
mem_limit: 512m
The risky example is loaded below. Paste your own file to check it for this and every other Docker Compose rule. It runs in your browser; nothing is uploaded.
Parsed in your browser. Nothing is uploaded.
1 service defined: app.
Runs the image example/app:1.4.2.
Limits memory to 512m. The container is killed if it exceeds this.
"no": Docker does not restart the container automatically, whether it crashed or the host rebooted.
Both restart the container after it exits. With always, a container you stopped manually starts again when the Docker daemon restarts; with unless-stopped it stays stopped.
Yes. The explainer accepts either restart or deploy.restart_policy on the service.