Error "The input device is not a TTY"
For docker run
DON'T USE -it
flag
(as said BMitch)
And it's not exactly what you are asking, but would be also useful for others:
For docker-compose exec
use -T
flag!
The -T key would help people who are using docker-compose exec! (It disable pseudo-tty allocation)
For example:
docker-compose -f /srv/backend_bigdata/local.yml exec -T postgres backup
or
docker-compose exec -T mysql mysql -uuser_name -ppassword database_name < dir/to/db_backup.sql
Remove the -it
from your cli to make it non interactive and remove the TTY. If you don't need either, e.g. running your command inside of a Jenkins or cron script, you should do this.
Or you can change it to -i
if you have input piped into the docker command that doesn't come from a TTY. If you have something like xyz | docker ...
or docker ... <input
in your command line, do this.
Or you can change it to -t
if you want TTY support but don't have it available on the input device. Do this for apps that check for a TTY to enable color formatting of the output in your logs, or for when you later attach to the container with a proper terminal.
Or if you need an interactive terminal and aren't running in a terminal on Linux or MacOS, use a different command line interface. PowerShell is reported to include this support on Windows.
What is a TTY? It's a terminal interface that supports escape sequences, moving the cursor around, etc, that comes from the old days of dumb terminals attached to mainframes. Today it is provided by the Linux command terminals and ssh interfaces. See the wikipedia article for more details.
To see the difference of running a container with and without a TTY, run a container without one: docker run --rm -i ubuntu bash
. From inside that container, install vim with apt-get update; apt-get install vim
. Note the lack of a prompt. When running vim against a file, try to move the cursor around within the file.