Because you are attached to the standard streams of the container. It would be the same with compose where you probably use up -d
to run in detached mode. hello world “works” because that just gives you an output and stops. It is about what runs inside the container.
Run docker run -d caddy
, but properly running a server container requires more configuration, not to mention port forwarding.
PS.: When you share terminal outputs, code or logs, please, follow the formatting guide: How to format your forum posts