web won't stay up. docker ps never shows it; docker ps -a shows it Exited (0) seconds after starting. The image is the stock nginx:alpine, which normally runs forever. There's no crash, no error — exit code 0 — yet it refuses to serve. Figure out why an nginx container exits cleanly instead of running, and get it serving.
web — nginx:alpine, Exited (0), deployed seconds ago.$ docker ps -a
CONTAINER ID IMAGE COMMAND STATUS NAMES
9e9e9e9e9e9e nginx:alpine "nginx -t" Exited (0) 1 minute ago web
$ docker logs web
nginx: configuration file /etc/nginx/nginx.conf test is successful
You've solved it when:
nginx -t, a config test) instead of the
image's default that runs the server — so it does its job and exits 0.
This is not a crash, a bad image, or a config error (the config test even
passed).
web up running by launching it with the image'sdocker run ... nginx:alpine
without the trailing nginx -t.
docker CLI only.web in status == running (serving, not a one-shot).docker run nginx:alpine nginx -t vs docker run nginx:alpine — whatnginx -t do to the image's CMD?
Exited (0) (clean exit) a useful clue that the container *didExited (1)/(137)?
command: line in a compose file produce the same trap?