Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is docker exec combining STDERR and STDOUT streams

Tags:

docker

Here's an example of outputting stderr using docker exec, and the output is sent to STDOUT.

$ docker exec -t 09b24cd7fa69 ls nosuchfile 1>docker.out 2>docker.err 
$ cat docker.out 
ls: cannot access 'nosuchfile': No such file or directory
$ cat docker.err 
$
like image 767
maged Avatar asked Mar 02 '18 00:03

maged


People also ask

What is the difference between Docker Exec and run?

Docker Run vs Docker Exec! This is a fairly common question – but has a simple answer! In short, docker run is the command you use to create a new container from an image, whilst docker exec lets you run commands on an already running container! Easy!

What is TTY in Docker exec?

The -t (or --tty) flag tells Docker to allocate a virtual terminal session within the container. This is commonly used with the -i (or --interactive) option, which keeps STDIN open even if running in detached mode (more about that later).

When should I use docker compose?

Docker Compose is an orchestration tool for Docker that allows you to define a set of containers and their interdependencies in the form of a YAML file. You can then use Docker Compose to bring up part or the whole of your application stack, as well as track application output, etc.

What docker compose up does?

The docker compose up command aggregates the output of each container (like docker compose logs --follow does). When the command exits, all containers are stopped. Running docker compose up --detach starts the containers in the background and leaves them running.


1 Answers

The problem is in the -t flag. Without it STDOUT and STDERR work as expected.

like image 188
maged Avatar answered Nov 15 '22 06:11

maged