I am trying to build services using docker-compose but containers started using docker-compose is stopping immediately as compose script is over. But when i am creating containe
If you use bash
as the command
, but without a terminal, it will exit immediately. This is because when bash starts up, if there is no terminal attached, and it has no script or other command to execute, it has nothing to do, so it exits (by design).
You can either use a different command
, or attach a terminal with tty: true
as part of the definition of this service.
services:
composetestdb:
tty: true
...