-: In the last section, we created our Docker file
and built a new image for our new application.
We should now be able to start up our application
by running Docker Run,
and then we'll specify the image we just created.
So you will put in your Docker username/visits.
Now remember, you do not have to specify the tag
by putting on :latest at the end,
but you optionally can if you want to.
So we can run this right here
and it will start up our application.
Now you'll notice that we immediately get an error message,
it says Redis connection
to something, something, something failed.
So our application is attempting to start up
but there's no Redis server running for it to connect to.
So in this section, we're gonna focus on
getting a separate container running a Redis server.
Now, as far as getting up a separate Redis server goes,
well, it's gonna be pretty darn straightforward.
We're gonna run the same exact command
that we've ran throughout this course.
I'll run Docker Run Redis like so.
And so, that's gonna reach out to the Docker Hub,
it's gonna pull down the Redis instance
and it'll start up a copy of Redis on our local machine.
And boom, just like that, there's our Redis server.
So that's it, that's the Redis instance.
We're gonna use no customization
to the Docker image for it whatsoever.
So now that we have our Docker,
excuse me, our Redis server running,
I'm gonna open up a second terminal window
and inside the second window
I'll now try running Docker Run my image again.
So I'll say Docker Run StevenGrider/visits.
Let's run that.
And you'll notice,
well, it looks like we still have the same error message
we had before, even though we are now running a Redis server
inside of a separate container.
So what's the problem?
Well, let's think about it for a second.
Here's what's going on on your computer right now.
You've got a Node application in one container
and the Redis application in the separate Docker container.
Now, these two containers do not have any automatic
communication between the two whatsoever.
They are two absolutely isolated processes
that don't have any communication.
So in order to make sure that our Node app has the ability
to kind of reach out to the Redis server
and store information or work with it in some fashion,
we need to set up some networking infrastructure
between the two.
Now, when it comes to setting up some networking
functionality between two separate containers,
we have for right now, two options to look at.
So here's our two options.
We can either make use of the Docker CLI
that we've been making use of throughout this course so far.
I'm talking about the Docker command
that we've been using at our terminal
throughout this entire course.
This built in Docker CLI has functionality
tied to it that will allow us to set up a network
between two separate containers.
However, there's a little issue with it,
and the issue is basically,
just that it's a real pain in the neck to do.
When you make use of Docker CLI to set up some networking,
it's going to involve a handful of different commands
that have to be reran every single time
you start up your different containers.
Now, of course, we could make some type of little script
to run all that stuff for us
but certainly it's gonna involve a lot of typing
and a lot of thought on how we're gonna set up
all this networking stuff.
I'm gonna be honest with you, I have just about never seen
people in industry ever making use of the Docker CLI.
Let me be very clear here,
never making use of Docker CLIs built in networking features
to connect two containers together.
Much more frequently, what you're going to see,
and what you and I are going to do inside this course,
is we're gonna make use of a separate CLI tool
called Docker Compose.
Docker Compose is a separate tool that gets installed
along with Docker.
So if you, right now flip back over to your terminal
and run Docker-Compose, like so,
you should see some content appear on the screen
and will list out a series of different commands
for you to run.
Docker Compose is a separate CLI,
it's already installed on your machine.
Now when you start introducing Docker Compose,
it's gonna very quickly starting getting confusing
what Docker Compose does and what Docker CLI does,
and what the relationship between the two is.
So the best thing I could tell you,
is that Docker Compose really exists to keep you
from having to write out a ton
of different repetitive commands with the Docker CLI.
So throughout this course, we've been running stuff
like Docker Run and Docker Attach and Exec
and we've been specifying ports and tags
and all this stuff just all the time.
Now, definitely as we learn this stuff,
we need to use Docker CLI and learn it.
But at a certain point in time you say,
"Okay, I understand this Docker CLI stuff,"
and you get tired of writing out those commands.
And so one of the big purposes of Docker Compose
is to just avoid having to write out all these really
annoying tiny little options every time
you want to start up a container.
The other big thing that Docker Compose
is going to do for us, is it's going to make it very easy
and very straightforward to start up multiple
Docker containers at the same time,
and automatically connect them together
with some form of networking.
And it's all gonna happen
behind the scenes for us quite automatically.
So again, as soon as you start seeing this terminology here
of Docker Compose,
keeping all these Docker terms straight in your head
gets a little bit confusing.
But I'm gonna tell you this right now,
I'm gonna repeat it several times.
The purpose of Docker Compose is to essentially
function as Docker CLI but allow you to kind of issue
multiple commands much more quickly.
So let's take a quick break right here.
We're gonna come back to the next section
and we're gonna get a little bit more familiar
with Docker Compose and how it works.