-: Much earlier in this course, like in the first one
or two sections, you saw me start up a new copy
of Redis on my computer by using docker.
As a reminder, Redis is an in-memory data store
that's very commonly used with web applications.
You saw me start up a Redis instance using docker
and it seemed to be really easy and very straightforward.
But I wanna show you kind of an oddity around using Redis
with docker very quickly.
I took the liberty of installing Redis
on my local machine directly
without docker being involved whatsoever.
'Cause I wanna show you the normal way
in which we might interact with Redis.
I'm gonna first start up an instance
of the Redis server by running Redis server.
Now again, I am able to run this command
because I installed Redis on my local machine
without docker involved.
Chances are you do not have Redis installed
on your computer, so don't try to run this command
because it's probably going to result in an error.
Now when I run that command, you're gonna see
that, yep, I get an instance of the Reddit server running.
It's in memory, it's ready to store data
or do whatever I need it to do.
The one of the very common ways in which we can kind of poke
into this thing or into this server
and inspect the data
that is inside of it, is by using a second program,
called the Redis CLI.
So on my computer, I've already got Redis server running.
I'm gonna now start up a second program called Redis CLI.
And again, the entire purpose
of this thing is to kind of reach
into that server and poke around inside of it.
So, I'm gonna open up a second terminal window
and I'll run Redis CLI
and that gives me a little prompt right here
that allows me to issue commands directly
to the running Redis server.
And so I can do something like store my number
or excuse me, not store, but set my number, is five
and then I can then retrieve that value
and it prints out five.
So this right here is the normal interaction
that you would see with Redis, with Redis CLI.
Clearly it's really nice to be able to run the Redis CLI
and interact directly with information
inside that running Redis server.
All right,
so now you're probably wondering where am I going with this?
Well, let's try starting up Redis using docker
and then you're gonna very quickly see some
interesting behavior around Redis CLI.
So let's give it a shot.
I'm gonna stop my running stuff
and then I'm going to start up an instance of Redis
on my machine using Docker Run Redis.
Now it's gonna start up just about instantly for me.
For you it might take a second or two as it has
to download the image
but overall it should be pretty darn quick.
When you start up Redis, you might see a couple of warnings.
Those are totally fine, you can ignore them.
Just make sure that the very last line
that you see is something
that says, ready to accept connections.
So as long as you see that, you're good to go.
All right, so this right here,
what we are running right here is the Redis server.
So I now want to start up a copy of the Redis CLI
and try to work with the information
that is being handled inside of the server.
As you saw just a moment ago, I was able
to open up a second console window and run Redis CLI.
So, well maybe for docker being involved here,
maybe we just have to run like Red CLI here.
Oh no, that clearly doesn't do anything.
Maybe we need to start up a second terminal window
and try running Redis CLI there, let's try that.
We'll open up a second window and then run Redis CLI.
Now chances are you're gonna see a message
that says something
like, Command not recognized or Command not Found.
I see something that says, could not connect to Redis.
So what's going on here? Well, let's look at a diagram.
So just a second ago, we started up a new container
that is running Redis server.
Now, Redis is running only inside this container.
So if I tried to run Redis CLI outside the container,
outside the container I have no access
to anything that's going on inside there.
And so, there is no Redis CLI command
to run outside the container.
If we want to start up the CLI, we need
to somehow get into this container
and execute a second command inside of it, like this.
We need to start up a second program inside the container.
So to figure out how to do so let's take a quick break.
We'll come back to the next section
and figure out how we can execute a second command
inside of a running container.
So I'll see you in just a minute.