What is “tty: true” in docker-compose.yml?

KeisukeKoshikawa
2 min readMay 18, 2021

Many docker-compose.yml writing articles mention “tty: true” without explanation.

So I had a question Why need to write “tty: true” in your docker-compose.yml?

In this article, I’d like to explain what is tty: true.

What is tty: true?

If you write “tty: true” in the docker-compose.yml, you will be able to “keep the container running”.

This is the same as writing -t in the docker command.

In foreground mode (the default when -d is not specified), docker run can start the process in the container and attach the console to the process’s standard input, output, and standard error. It can even pretend to be a TTY (this is what most command line executables expect) and pass along signals. All of that is configurable:Ref: https://docs.docker.com/engine/reference/run/#foreground

What is tty?

A pseudo terminal (also known as a tty or a pts ) connects a user’s “terminal” with the stdin and stdout stream, commonly (but not necessarily) through a shell such as bash . … In the case of docker, you’ll often use -t and -i together when you run processes in interactive mode, such as when starting a bash shell.

tty is unix command so can execute your terminal. The command used to display the device file name of the connected terminal.

$ tty
/dev/ttys001

Thank you for reading.

Referenced articles

https://docs.docker.com/engine/reference/run/#foreground

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

KeisukeKoshikawa
KeisukeKoshikawa

Written by KeisukeKoshikawa

Web Developer in Japan. I’ve been developing with ROR for less than two years. also have experience in maintaining and operating SPA with Angular(v2 ~ ).

Responses (1)

Write a response