Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does "attach to standard streams" mean in docker?

Tags:

docker

stdout

I am reading the spec of the run command and see the following:

-i : Keep STDIN open even if not attached

and

-a=[] : Attach to STDIN, STDOUT and/or STDERR

and

You can specify to which of the three standard streams (STDIN, STDOUT, STDERR) you’d like to connect

But I lack of understanding: what does it mean to "connect a container to a standard stream?" Can somebody explain? What does for example the -i parameter do?

like image 949
Skip Avatar asked Oct 23 '25 14:10

Skip


1 Answers

Well, STDIN (Standard Input), STDOUT (Standard Output), STDERR (Standard Error) are three standard stream.

Normally, STDIN means keyboard, STDOUT and STDERR mean the direct screen display.

So, if you want to give your container some input from keyboard, you need to connect it to the STDIN. And if you want your container print the result on the screen, you may need to connect it to STDOUT and STDERR.

Otherwise, your container can run in the background. Input may come from, say, network and output may be stored in a log file.

like image 125
Zhigong Li Avatar answered Oct 26 '25 20:10

Zhigong Li