Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bash exits after successfully running docker-compose

I can ssh onto a machine and run the following script

echo testing
docker-compose exec -T meteor php artisan down
echo done

which returns

testing
Application is now in maintenance mode.
done

However it I try and run that command over ssh it exits immediately after the docker-compose call.

ssh [email protected] << EOF
    echo testing
    docker-compose exec -T meteor php artisan down
    echo done
EOF

gives

testing
Application is now in maintenance mode.

ie done is missing

I can get it to continue by adding && after the docker-compose command but i've got a long script and it makes it ugly and error prone if I have to explicity state this.

Any idea why this is happening and what I can change to fix it.


Update

I removed the -T from docker-compose and the script ran to completion however it gave the message the input device is not a TTY. It appears it can't allocate the interactive console. After a bit more googling I found that I can call

export COMPOSE_INTERACTIVE_NO_CLI=1

And then it will run to completion without giving error messages.

Thanks all for the help :)

like image 708
FloatingKiwi Avatar asked Feb 07 '26 01:02

FloatingKiwi


1 Answers

The issue was being caused by the -T flag to docker-compose.

This was added because an error message was being printed if it wasn't there. the input device is not a TTY

I found you could prevent docker-compose from creating an interactive terminal if you use

export COMPOSE_INTERACTIVE_NO_CLI=1

Then the script runs correctly without the -T option.

like image 93
FloatingKiwi Avatar answered Feb 09 '26 07:02

FloatingKiwi