3

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 :)

4
  • What exit code is docker-compose returning? Commented Dec 11, 2018 at 16:13
  • It exits before I can print the code. Ah, actually if I use && echo $? i get it. 130. Which seems to be that a ctrl + c was sent ... but not by me.... Any way I can reset this? Commented Dec 11, 2018 at 16:40
  • seems odd to me that && echo $? executes for a nonzero code, but perhaps the environment is exiting because of what it sees as a failure. Personally, I would throw the whole thing into a script with error checking and logging &c, but if it isn't worth all that to you and you just want to plow ahead, add a ||: on the end of the docker-compose command to tell it to just shut up and keep going. Commented Dec 11, 2018 at 16:46
  • Your script inherits its standard input from ssh, so it's possible that docker-compose is reading from its standard input, which means it would read the echo done line before the remote shell that ran docker-compose gets the chance. Commented Dec 11, 2018 at 21:59

1 Answer 1

3

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.