-: In the last section,
we started up a new copy of the Reddis container image.
Inside there we have a running copy of the Reddis server
and we now need to figure out how we can somehow
start up the Reddis CLI also inside of that container.
To do so we're going to be making use
of another Docker command.
So the Docker command we're going to use is Docker exec.
Exec is short for execute,
and we use it to execute an additional command
inside of a container.
We're going to write,
Docker exec, we'll then put down it, dash it.
This little argument right here allows us
to type input directly into the container.
We then provide the container ID and then
the command that we want to execute inside of the container.
So let's try doing this right now and seeing what happens.
I'm gonna first go back over to my turn,
I'm gonna verify that my Reddis container is still running.
I can either look at it inside the running window,
alternatively, I could run Docker PS and see,
yep I still have that Reddis image still going.
So then to start up a second program inside the container
I'll run Docker exec.
Oops, forgot one thing here,
we gotta get the container's id.
We'll do Docker ps and there's the ID right there.
So I'll do Docker exec, dash it, I'll paste in the id
and then the command that I want to execute
inside there is Reddis dash CLI.
And when I do so, you'll see that I now get that
a little bit more familiar looking Command Frontier
and I can write out something like set my value five
and get my value, and it retrieves five.
So by using the exec command, we were able to
start up a second running program inside of our container.
And the dash IT flag right here allowed us to enter
in text on our keyboard
and have it be sent into that running container.
As a very quick exercise
let's try removing the IT flag there
and seeing what happens.
I'm gonna exit this by hitting control C on my keyboard
and then I'll do Docker exec again.
But this time I'm going to leave off the IT flags.
So I'll do Docker exec, the id, and then Reddis CLI.
And you'll notice that this time around
I just got kicked directly back to my terminal.
I got kicked directly back because Reddis CLI was started up
but we did not get the ability to enter in any text.
So when Reddis CLI was started up
but it very quickly realized,
"Hey I don't have any possibility
of getting any text input."
It decided to just entirely close down
and kick us back to our terminal.
Now this idea behind kind of adding on this IT flag
and adding in text here is actually something
that's rather important in the world of Docker.
So let's take a quick pause right here
and we're going to come back in the next section
and kind of expand upon what IT right here means.
So I'll see you in just a minute.