In docker, I can simply use the -t switch to have docker run allocate a pseudo-tty (in these examples I'm using nohup to detach from my real tty):
$ nohup docker run debian tty # Produces "not a tty"
$ nohub docker run -t debian tty # Produces "/dev/pts/0"
I'm trying to achieve the same result with docker-compose. I have the following docker-compose.yml:
version: "3"
services:
myservice:
image: debian
tty: true
The I run it with and without nohup:
$ docker-compose run myservice tty # Produces "/dev/pts/0"
$ nohup docker-compose run myservice tty # Produces "not a tty"
The documentation of docker-compose run says that I can use -T to disable the allocation of a pseudo-tty, but there does not seem to be a way to explicitely enable it (which should not be necessary as by default a tty should be allocated).
-TDisable pseudo-tty allocation. By defaultdocker-compose runallocates a TTY.
Am I doing something wrong?
Include the following in your docker-compose.yml for your service:
services:
myservice:
...
stdin_open: true # docker run -i
tty: true # docker run -t
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With