In the last couple of videos we discussed Docker and Cuban Eddie's.
Hopefully you had a chance to go through those appendix videos at the very end of the course and get
more friendly with Docker if you didn't know about it already.
Some sign here your doctor Perot now right.
I do not expect you to be a doctor Perot.
I really just expect you to have a basic understanding of what a container is.
When images how to create images how to create containers in a couple of commands around them just to
reinforce them that knowledge in this video we're going to start to dock arise.
Our post service and then we're going to play around with the image and container just a little bit.
So let's get to it in order to dock rise.
Our postal service we're going to have to create an image out of it to make an image remember we make
a docker file and then run the docker build command in this diagram.
I've listed out the different commands that we're going to write out inside of the docker file for the
post project.
The first thing we'll do is specify our base image of node Alpine.
Well then specify a working directory which is going to set the working directory for the rest of all
these commands inside of our Docker file.
Well then copy over just the package not just on file installer dependencies.
Using that file and copy over all the other source code from our project and then finally we'll set
up our default command of NPM start to start up our container so let's flip over to our code editor
and start putting this Docker file together back inside my editor.
I'll find the post directory inside there I'll make a new file called Docker file and remember it has
to have a capital D and no extension on it whatsoever then we'll write out those series of commands
so we're just looking at inside that diagram.
Well first specify our base image well then set up a working directory of slash app we will copy over
just the package dot JS on file and then we will run npm install to install all of our dependencies
after that we will copy over everything else from our post directory.
So it really just means our index not just file.
And then finally we'll setup our default command of NPM start
and that should be at now.
One other thing we're going to do really quickly.
Remember that if you went through those videos in the appendix we usually don't want to include any
install dependencies that are on our local machine.
So in our case that would be the node modules folder in order to make sure that we don't send all those
dependencies over during the image building process.
We're going to create a file inside this post directory called Dot.
Make sure you get a dot in there Docker.
Ignore and then inside of here we will write out node modules like so that's going to make sure that
during the image building process we do not attempt to copy over at that node modules directory because
the image is going to install all the relevant dependencies when it is being built on its own.
OK so let's now close those two files.
Well then go back over to our terminal
I will change into the post directory and inside there we'll do a docker build dot that's going to pull
down the node based image set our working directory copy over a package that Jason install dependencies
using that patch dot Jason File the dependencies should be installed rather quickly.
Will then copy over all of the other files inside of our project and then set up that default command
and at the very end.
We get the I.D. of the image that was just built so we can now create an instance of that image or in
other words a container by copying that idea and running Docker run and then pasting the idea of that
image and there we go.
Looks like our server is running successfully okay.
That's a good step forward.
Let's take a pause right here and then as I mentioned we'll do a quick review on some basic commands
with Docker in the next video just to make sure it's really clear how we can work with a running container.