WEBVTT

00:00.810 --> 00:02.940
-: In the last section, we created our Docker file

00:02.940 --> 00:05.940
and built a new image for our new application.

00:05.940 --> 00:07.800
We should now be able to start up our application

00:07.800 --> 00:10.020
by running Docker Run,

00:10.020 --> 00:12.390
and then we'll specify the image we just created.

00:12.390 --> 00:17.283
So you will put in your Docker username/visits.

00:19.080 --> 00:22.170
Now remember, you do not have to specify the tag

00:22.170 --> 00:25.260
by putting on :latest at the end,

00:25.260 --> 00:27.270
but you optionally can if you want to.

00:27.270 --> 00:28.530
So we can run this right here

00:28.530 --> 00:30.480
and it will start up our application.

00:30.480 --> 00:32.640
Now you'll notice that we immediately get an error message,

00:32.640 --> 00:33.750
it says Redis connection

00:33.750 --> 00:36.300
to something, something, something failed.

00:36.300 --> 00:38.430
So our application is attempting to start up

00:38.430 --> 00:41.640
but there's no Redis server running for it to connect to.

00:41.640 --> 00:43.200
So in this section, we're gonna focus on

00:43.200 --> 00:47.340
getting a separate container running a Redis server.

00:47.340 --> 00:50.490
Now, as far as getting up a separate Redis server goes,

00:50.490 --> 00:52.560
well, it's gonna be pretty darn straightforward.

00:52.560 --> 00:54.150
We're gonna run the same exact command

00:54.150 --> 00:56.430
that we've ran throughout this course.

00:56.430 --> 01:01.430
I'll run Docker Run Redis like so.

01:01.632 --> 01:03.420
And so, that's gonna reach out to the Docker Hub,

01:03.420 --> 01:05.040
it's gonna pull down the Redis instance

01:05.040 --> 01:07.830
and it'll start up a copy of Redis on our local machine.

01:07.830 --> 01:10.470
And boom, just like that, there's our Redis server.

01:10.470 --> 01:12.330
So that's it, that's the Redis instance.

01:12.330 --> 01:14.100
We're gonna use no customization

01:14.100 --> 01:16.890
to the Docker image for it whatsoever.

01:16.890 --> 01:18.349
So now that we have our Docker,

01:18.349 --> 01:19.740
excuse me, our Redis server running,

01:19.740 --> 01:22.380
I'm gonna open up a second terminal window

01:22.380 --> 01:23.790
and inside the second window

01:23.790 --> 01:28.350
I'll now try running Docker Run my image again.

01:28.350 --> 01:32.223
So I'll say Docker Run StevenGrider/visits.

01:33.510 --> 01:34.353
Let's run that.

01:35.760 --> 01:36.900
And you'll notice,

01:36.900 --> 01:39.180
well, it looks like we still have the same error message

01:39.180 --> 01:42.900
we had before, even though we are now running a Redis server

01:42.900 --> 01:44.520
inside of a separate container.

01:44.520 --> 01:46.140
So what's the problem?

01:46.140 --> 01:48.600
Well, let's think about it for a second.

01:48.600 --> 01:50.850
Here's what's going on on your computer right now.

01:50.850 --> 01:53.550
You've got a Node application in one container

01:53.550 --> 01:57.450
and the Redis application in the separate Docker container.

01:57.450 --> 02:01.020
Now, these two containers do not have any automatic

02:01.020 --> 02:03.180
communication between the two whatsoever.

02:03.180 --> 02:06.510
They are two absolutely isolated processes

02:06.510 --> 02:08.640
that don't have any communication.

02:08.640 --> 02:11.130
So in order to make sure that our Node app has the ability

02:11.130 --> 02:13.020
to kind of reach out to the Redis server

02:13.020 --> 02:15.810
and store information or work with it in some fashion,

02:15.810 --> 02:18.330
we need to set up some networking infrastructure

02:18.330 --> 02:20.010
between the two.

02:20.010 --> 02:22.230
Now, when it comes to setting up some networking

02:22.230 --> 02:24.510
functionality between two separate containers,

02:24.510 --> 02:27.603
we have for right now, two options to look at.

02:28.860 --> 02:30.420
So here's our two options.

02:30.420 --> 02:32.130
We can either make use of the Docker CLI

02:32.130 --> 02:34.650
that we've been making use of throughout this course so far.

02:34.650 --> 02:36.600
I'm talking about the Docker command

02:36.600 --> 02:37.890
that we've been using at our terminal

02:37.890 --> 02:39.720
throughout this entire course.

02:39.720 --> 02:42.150
This built in Docker CLI has functionality

02:42.150 --> 02:44.610
tied to it that will allow us to set up a network

02:44.610 --> 02:47.010
between two separate containers.

02:47.010 --> 02:49.050
However, there's a little issue with it,

02:49.050 --> 02:50.250
and the issue is basically,

02:50.250 --> 02:53.550
just that it's a real pain in the neck to do.

02:53.550 --> 02:55.980
When you make use of Docker CLI to set up some networking,

02:55.980 --> 02:58.740
it's going to involve a handful of different commands

02:58.740 --> 03:00.960
that have to be reran every single time

03:00.960 --> 03:04.410
you start up your different containers.

03:04.410 --> 03:06.510
Now, of course, we could make some type of little script

03:06.510 --> 03:07.680
to run all that stuff for us

03:07.680 --> 03:09.990
but certainly it's gonna involve a lot of typing

03:09.990 --> 03:11.700
and a lot of thought on how we're gonna set up

03:11.700 --> 03:13.350
all this networking stuff.

03:13.350 --> 03:15.960
I'm gonna be honest with you, I have just about never seen

03:15.960 --> 03:20.960
people in industry ever making use of the Docker CLI.

03:21.090 --> 03:22.320
Let me be very clear here,

03:22.320 --> 03:25.200
never making use of Docker CLIs built in networking features

03:25.200 --> 03:27.450
to connect two containers together.

03:27.450 --> 03:29.280
Much more frequently, what you're going to see,

03:29.280 --> 03:31.500
and what you and I are going to do inside this course,

03:31.500 --> 03:35.670
is we're gonna make use of a separate CLI tool

03:35.670 --> 03:37.563
called Docker Compose.

03:38.910 --> 03:42.240
Docker Compose is a separate tool that gets installed

03:42.240 --> 03:43.410
along with Docker.

03:43.410 --> 03:46.380
So if you, right now flip back over to your terminal

03:46.380 --> 03:50.040
and run Docker-Compose, like so,

03:50.040 --> 03:52.080
you should see some content appear on the screen

03:52.080 --> 03:53.670
and will list out a series of different commands

03:53.670 --> 03:54.503
for you to run.

03:56.250 --> 03:58.350
Docker Compose is a separate CLI,

03:58.350 --> 04:00.330
it's already installed on your machine.

04:00.330 --> 04:02.550
Now when you start introducing Docker Compose,

04:02.550 --> 04:04.860
it's gonna very quickly starting getting confusing

04:04.860 --> 04:07.710
what Docker Compose does and what Docker CLI does,

04:07.710 --> 04:09.900
and what the relationship between the two is.

04:09.900 --> 04:11.430
So the best thing I could tell you,

04:11.430 --> 04:14.610
is that Docker Compose really exists to keep you

04:14.610 --> 04:16.290
from having to write out a ton

04:16.290 --> 04:20.340
of different repetitive commands with the Docker CLI.

04:20.340 --> 04:21.870
So throughout this course, we've been running stuff

04:21.870 --> 04:24.750
like Docker Run and Docker Attach and Exec

04:24.750 --> 04:26.760
and we've been specifying ports and tags

04:26.760 --> 04:28.713
and all this stuff just all the time.

04:29.580 --> 04:31.470
Now, definitely as we learn this stuff,

04:31.470 --> 04:33.810
we need to use Docker CLI and learn it.

04:33.810 --> 04:35.227
But at a certain point in time you say,

04:35.227 --> 04:37.860
"Okay, I understand this Docker CLI stuff,"

04:37.860 --> 04:39.960
and you get tired of writing out those commands.

04:39.960 --> 04:42.510
And so one of the big purposes of Docker Compose

04:42.510 --> 04:45.000
is to just avoid having to write out all these really

04:45.000 --> 04:47.220
annoying tiny little options every time

04:47.220 --> 04:48.870
you want to start up a container.

04:50.130 --> 04:51.480
The other big thing that Docker Compose

04:51.480 --> 04:54.480
is going to do for us, is it's going to make it very easy

04:54.480 --> 04:56.430
and very straightforward to start up multiple

04:56.430 --> 04:58.230
Docker containers at the same time,

04:58.230 --> 05:00.270
and automatically connect them together

05:00.270 --> 05:02.400
with some form of networking.

05:02.400 --> 05:03.233
And it's all gonna happen

05:03.233 --> 05:06.120
behind the scenes for us quite automatically.

05:06.120 --> 05:08.520
So again, as soon as you start seeing this terminology here

05:08.520 --> 05:09.960
of Docker Compose,

05:09.960 --> 05:12.360
keeping all these Docker terms straight in your head

05:12.360 --> 05:13.620
gets a little bit confusing.

05:13.620 --> 05:14.790
But I'm gonna tell you this right now,

05:14.790 --> 05:16.410
I'm gonna repeat it several times.

05:16.410 --> 05:19.110
The purpose of Docker Compose is to essentially

05:19.110 --> 05:22.710
function as Docker CLI but allow you to kind of issue

05:22.710 --> 05:25.050
multiple commands much more quickly.

05:25.050 --> 05:26.670
So let's take a quick break right here.

05:26.670 --> 05:27.870
We're gonna come back to the next section

05:27.870 --> 05:29.700
and we're gonna get a little bit more familiar

05:29.700 --> 05:31.653
with Docker Compose and how it works.
