How to test that a Docker image boots before you deploy it
Catch a localhost bind, a wrong port, a missing env var, an out-of-memory crash or a failing health check locally, before the deploy fails.
Most failed container deploys fail at boot, not at build: the server binds
127.0.0.1, listens on a hard-coded port instead of $PORT, crashes on a
missing environment variable, runs out of memory, or never passes its health
check. Each of these passes docker build and often docker run on your
laptop. gregale doctor --image IMAGE --boot runs the image with your local
Docker the way Gregale starts it, and names the mistake before you deploy. It
needs no Gregale account to run against a public or local image.
Gregale publishes this page. The checks come from the container compatibility docs; the output is from our own test on December 1, 2026, described below.
Why docker run is not enough
A hosting platform starts your image differently from how you start it at home:
- It sets
PORTand sends traffic only to that port.docker run -p 3000:3000works for an app that ignoresPORTand listens on 3000. - It connects from outside the container. A server bound to
127.0.0.1answerscurlinside the container and nothing from outside. - It caps memory at the app's size, with no swap. Your laptop lets the container use whatever Docker Desktop has.
- It waits for a health path to answer 2xx before routing traffic, and
sends the app's public host name, which an allow-list such as Django's
ALLOWED_HOSTSmay refuse. - It runs linux/amd64. An image built on an Apple silicon Mac is arm64 unless you asked for amd64.
The result is a deploy that builds, uploads and then fails on the platform, a few minutes later, with a less specific error.
Check the image
# An image in a registry
gregale doctor --image ghcr.io/acme/api:1.2 --boot
# An image you just built locally
docker build --platform linux/amd64 -t api:dev .
gregale doctor --image api:dev --boot --env-file .env.test
# Probe the readiness route you deploy with, at the RAM you deploy with
gregale doctor --image api:dev --boot --healthcheck-path /healthz --ram 256
--boot runs the image as linux/amd64, with PORT set to the serving port
(the single exposed TCP port, otherwise 8080). It reports whether the
container started or crashed, with its last output, whether it answered
GET / on 0.0.0.0:$PORT, and whether it was still running 10 seconds after
it started. When nothing answers, it reads the container's listening sockets
and names the mistake; that diagnosis needs cat in the image.
| Flag | What it does |
|---|---|
--env-file FILE | Variables the app needs to start, in docker env-file format |
--healthcheck-path /healthz | Probes your readiness route instead of / and requires a 2xx |
--ram MB | Sets the memory cap; otherwise the app's RAM with --app, or your plan default |
--app SLUG | Uses an existing app's RAM and public host name |
--execution-mode worker|job | Checks a process that serves no HTTP |
--healthcheck-grpc | Calls the standard gRPC health service instead of HTTP |
The container is removed afterwards. Pass env that points at test resources, never production credentials: the process runs for real on your machine.
What each mistake looks like
We built one small Python HTTP server and switched its behavior with an
environment variable, then ran gregale doctor --image bootcheck:demo --boot
against each mode. These are the findings it printed.
Bound to localhost:
boot-listener — boot_not_listening
hint: Listening on 127.0.0.1:8080, not 0.0.0.0:8080; the platform cannot reach a loopback listener.
fix: Bind 0.0.0.0 (or ::) instead of 127.0.0.1/localhost.
Listening on a hard-coded port:
boot-listener — boot_not_listening
hint: Listening on 0.0.0.0:3000, not 0.0.0.0:8080 ($PORT).
fix: Bind 0.0.0.0 and read PORT, or EXPOSE the one port the app listens on so the platform sets PORT to it.
Crashing on a missing variable (exited after 2.5 s, with the container's last output):
boot-start — boot_exited
hint: The container exited with code 1 after 2.5 s.
container output (last lines):
KeyError: 'DATABASE_URL' is not set
Out of memory (the server allocated 400 MB at start, checked with
--ram 256):
boot-start — boot_oom_killed
hint: The container ran out of its 256 MB of memory (--ram) after 2.1 s; on Gregale the app would crash the same way.
Health path never ready (/healthz answered 503 through the 30-second
startup window):
boot-http — boot_health_failed
hint: GET /healthz last answered 503, and no answer within 30.0 s was 2xx.
A working image:
boot-start — answered in 1.1 s within 512 MB (the scale plan's default for a new app)
boot-listener — listening on 0.0.0.0:8080 ($PORT)
boot-http — GET /healthz → 200
boot-stay-up — stayed up 10.0 s
The command exited 1 on every broken mode and 0 on the working one, so the
same line works as a CI step. Warnings do not fail it; add --strict to fail
on them too. On an Apple silicon Mac, Docker runs the amd64 image under
emulation, so startup is slower than on Gregale: our first working run took
9.0 s to answer.
Check as part of the deploy
gregale deploy --local-image IMAGE --boot runs the same checks before the
image is saved or uploaded, with the deployment's health path and RAM:
gregale deploy --local-image api:dev --boot --healthcheck-path /healthz
A crash, a listener on the wrong address or port, an out-of-memory kill or a
failing health check stops the deploy with the findings, and nothing is
uploaded. When we deployed the localhost-bound image this way, the CLI printed
the same boot_not_listening finding, then nothing was uploaded, and no app
was created. --boot-env-file FILE passes variables to the local container
only; set them on the app with gregale env or gregale secrets for the
deployment.
Workers, jobs and gRPC
A worker or job serves no HTTP. With --execution-mode worker or job, the
boot publishes no port and judges the process the way Gregale does when it
first boots a deployment: a worker still running at the end of the
observation window works, a job that exited 0 has completed, and any other
exit is a startup failure. A worker that exits 0 is a warning, since it would
stop instead of working.
A gRPC service checked with --boot --healthcheck-grpc gets the standard
grpc.health.v1.Health/Check call over plaintext gRPC on $PORT, and passes
once it answers SERVING. An image with a Docker HEALTHCHECK also gets it
run, with its failure budget kept as on Gregale.
Plans
doctor --boot runs on your machine and is free. Deploying a container needs
a Gregale account: Free, Hobby ($10 a month), Pro ($30) or Scale ($99). A
container image that is not built on a Gregale base runs as a self-contained
full-rootfs deployment, which paid plans enable automatically and Free plans
opt into. See container compatibility,
Deploy a Docker container
and pricing.
For code rollback, see how to verify the exact container image before rollback, including a file checksum and a check of the stable URL.
For a complete port and readiness example, see deploy an ASP.NET Core .NET 10 API with Docker.
Questions
- Why does my container work with docker run but fail to deploy?
A platform starts the image differently: it sets PORT and sends traffic only there, connects from outside the container, caps memory with no swap, waits for a health path to answer 2xx, and runs linux/amd64. A server bound to 127.0.0.1, a hard-coded port or an app that needs more memory than the cap works on a laptop and fails after the deploy.
- How do I check that a Docker image will start before deploying?
gregale doctor --image IMAGE --boot runs the image with your local Docker the way Gregale starts it and reports whether it started, listened on 0.0.0.0:$PORT, answered HTTP and stayed up for 10 seconds. It exits 1 on a finding, so it works as a CI step.
- How do I find out if my container needs more memory?
Boot it with the memory cap it will get: gregale doctor --image IMAGE --boot --ram 256. An app that needs more is killed with boot_oom_killed, as it would be after the deploy. Raise the app’s RAM with gregale app update APP --ram MB or lower its memory use.
- Can the deploy refuse a broken image automatically?
Yes. gregale deploy --local-image IMAGE --boot runs the same checks before the image is uploaded. A crash, a wrong address or port, an out-of-memory kill or a failing health check stops the deploy, and nothing is uploaded.