Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get docker exec stdout to be as verbose as running command in container?

Tags:

docker

stdout

If I run a command using docker's exec command, like so:

docker exec container gulp

It simply runs the command, but nothing is outputted to my terminal window.

However, if I actually go into the container and run the command manually:

docker exec -ti container bash
gulp

I see gulp's output:

[13:49:57] Using gulpfile ~/code/services/app/gulpfile.js
[13:49:57] Starting 'scripts'...
[13:49:57] Starting 'styles'...
[13:49:58] Starting 'emailStyles'...
...

How can I run my first command and still have the output sent to my terminal window?

Side note: I see the same behavior with npm installs, forever restarts, etc. So, it is not just a gulp issue, but likely something with how docker is mapping the stdout.

like image 973
Michael Irigoyen Avatar asked Mar 09 '16 14:03

Michael Irigoyen


1 Answers

How can I run my first command and still have the output sent to my terminal window?

You need to make sure docker run is launched with the -t option in order to allocate a pseudo tty.
Then a docker exec without -t would still work.

I discuss docker exec -it here, which references "Fixing the Docker TERM variable issue ")

docker@machine:/c/Users/vonc/prog$ d run --name test -dit busybox
2b06a0ebb573e936c9fa2be7e79f1a7729baee6bfffb4b2cbf36e818b1da7349
docker@machine:/c/Users/vonc/prog$ d exec test echo ok
ok
like image 76
VonC Avatar answered Oct 19 '22 20:10

VonC