Docker: run a program requiring tty

I have a utility program that depends on the characteristics of the terminal. I want to execute it inside a docker container. (The program is not an interactive program as such. It is an old program that was written that way).

docker run -i -t or docker exec -i -t should open tty in the container. But here's what happens ..

 user@1755e1f3f735 :~/region/primer/cobol_v> kickstop [Error] Unable to run without terminal device (tty) user@1755e1f3f735 :~/region/primer/cobol_v> tty not a tty 

When the -t option to docker (run / exec) should give 'tty', tty commands return with 'not tty'. This is puzzling.

I tested this on openSuse and fedora23 hosts and images, if that matters. For this I used the terminal emulators "guake", MATE (Gnome?) With the same results.

Is there any solution? or is it by design and need to replace / rewrite my utility?

+5
source share
2 answers

I ran into the same problem and found that "docker exec -ti container script / dev / null" solved the problem.

After entering the container with the above command, I can use the screen normally.

Link: https://github.com/docker/docker/issues/8755

+1
source

I conducted several experiments, and here are the conclusions. Hope someone finds them helpful. (docker teams are not complete, but just brief)

 1. docker run -i -t > tty /dev/console > echo $TERM xterm >kickstop works!! 

2. docker -d followed by docker exec -i -t

 >tty not a tty >echo $TERM dumb >kickstop [Error] Unable to run without terminal device (tty) 

3. docker -d followed by docker attach you connect to / dev / console. There is no clue (because I use tail -f xxx.log to keep the container alive). Actually I need to stop my application from another terminal (using docker exec) and stop the container in order to return to the prompt (host shell)

4. docker start followed by docker attach as above

0
source

Source: https://habr.com/ru/post/1245225/


All Articles