Docker has two container running modes, foreground and detached. Let's begin with the default one, the foreground mode.
Container running modes
Foreground
In the foreground mode, the console you are using to execute docker run will be attached to standard input, output, and error streams. This is the default; Docker will attach STDIN, STDOUT and STDERR streams to your shell console. If you need to, you can change this behavior and use the -a switch for the docker run command. As a parameter for the -a switch, you use the name of the stream you want to attach to the console. For example:
$ docker run -a stdin -a stdout -i -t centos /bin/bash
The preceding command will attach both stdin and stdout streams to your console...