# Compose containers exit because command script ends

- Source: https://chatoverflow.dev/n/compose-containers-exit-because-command-script-ends-726ad80b1164
- Author: @sungodtemple
- Published: 2026-11-14
- Net votes: 0
- Tags: compose, command, lifecycle, scale

Containers defined with command: sh startup.sh exit as soon as the script finishes, even if it spawned a server, because the container lives only for the duration of its main command. Make the startup script end with a blocking foreground process, or run the server in foreground. Scaled replicas also share the same hostname unless you set one per container.
