In last section we found that we were able to connect to read a C lie inside of our running docker container
and notice how mine is still running over here on the second window.
By adding on the dash I t flag.
So when I did that we saw.
Yep we got this prompt here.
We could enter stuff in.
I could then first control C to exit back out.
However if I tried running this command without the I.T. flag it appeared that I just got kicked directly
back over to my terminal.
So in this section I want to give you a better idea of what this dash I.T. flag right here is really
doing for us.
The first thing you need to understand is a little bit more about how processes run inside of a Linux
environment.
As a quick reminder when you are running Docker on your machine every single container that you are
running is running inside of a virtual machine running Linux.
So these processes are really being executed inside of a Linux world.
Even if you're on Mac or Windows.
All right so that mind in this diagram we've got three different running processes all inside in theory
of a running container or really inside of a Linux environment.
Every process that we create in a Linux environment has three communication channels attached to it
that we refer to as standard in standard out and standard air these channels are used to communicate
information either in to the process or out of the process.
Standard in as you might guess is used to communicate information into the process.
So when you are at your terminal and you type stuff in the stuff you type is being directed into a running
standard and channel attached to say the red a apply the standard out channel that is attached to any
given process is going to convey information that is coming from the process.
So standard out might be redirected over to your running terminal and that's going to end up as being
stuff that is going to show up on the screen standard error is very similar but it conveys information
out of the process.
That is kind of like an error in nature.
So if red Seelye has some error inside of it that's can be communicated to the outside world over the
standard error channel and very similar to standard out.
That's going to be redirected to show up on the screen of your terminal.
So how does that relate to the I.T. flag.
When we do the docker Zac dash I.T. will the I.T. right here is actually two separate little flags.
In reality it's a dash eye and a dash t like so.
But by convention we usually just kind of shorten it down to be simply I.T. which is 100 percent equivalent
to the two separate flags the Dash I on here means when we execute this new command inside the container
we want to attach our terminal to the standard in channel of that new running process.
So by adding on the dash IV flag we are saying make sure that any stuff that I type gets directed to
standard in of red a CLIA the dash t flag is what kind of makes all this text show up a little bit pretty.
Now in reality it's doing a little bit more than that but at the end of the day the real effect that
the dashed you flag is to make sure that all the text that you are entering in and that is coming out
shows up in a nicely formatted manner on your screen.
And again it's doing a little bit more behind the scenes in that but at the end the day that's kind
of its effect let's try attaching or doing our Docker Zach on the running container one more time and
leaving off the dash t flag and just seeing what happens so I'll do a docker P.S. to get my containers
idea again and I'll do a docker exec and then we'll do only Dash I this time I'll put the idea in and
then I'll do red as CSI.
And so now this time you'll notice how I have my cursor over here.
It appears that this thing is waiting for input but I didn't do not see that kind of nicely formatted
indentation I saw before and if I put in like set my value five before I had a little bit of auto complete
functionality but this time that auto complete is definitely not there.
I can still run that command though and I still see okay and I can still do get my value and I still
see the value come out.
But again all this all this stuff is not nicely formatted and so that's kind of the purpose.
More or less kind of simplifying things here just a little bit of that dash t flag okay.
That's pretty much it.
That's the purpose of I.T. it allows us to have stuff that we type into our terminal directed into that
running process and allows us to get information out back over to our terminal.
So then mind let's take a quick break right here and continue in the next section.