In this video we're going to do a quick overview of some very basic Docker commands.
Just make sure these are fresh in your mind.
We're going to be running all the commands you see here quite a bit and also running some variance of
them that are based on Cuban eddies as opposed to Docker.
But don't worry about that part just yet.
So first command we're going to get a quick reminder on is darker build.
We did just run this last video but just as a reminder whenever we build a new image we can add on that
dash t flag that will tag the image that is created.
If we add on the dash t then we can easily create a new container at a image using either the image
I.D. or the image tag.
So for example if we go back over to our post service we can do a docker build a dash T and then usually
we'll put in our Docker I.D. which for me is Steven greater flash and then the name of our project.
So for us to be posts then after that we'd put in a dot to specify that we want to build this image
out of the current directory that we're in.
So I would run that the build runs very quickly because I've not made any changes to it from the last
video and now I can create an image out personally a container of this image using either the image
I.D. That's right there or the tag that is right there once we have built the image we can create and
start a container based on it by using Docker run and then providing either the image I.D. or the tag.
So for example I could now do Docker run Steven Greider slash posts like so and there we go there's
our post service.
Next up whenever we start up a container we can either just use Docker and by itself or alternatively
we can override the default command of the container by providing both that I.T. flag right there and
then the command that we want to execute instead the default one right there at the very end.
So for example I could start up that postal service container that we just created and start up a shell
inside there.
So essentially a terminal window inside that container rather than actually running the default command
which is NPM starts.
So we could do a docker run dash I.T. Steven Greider posts and I would put an S H which will start up
a shell inside there s h is short for the word shell.
It is a very specific type of shell essentially equivalent to if you're running bash right now on your
computer.
And so now rather than running our server inside there I've got a shell running and inside of here I
can run a typical commands all being executed inside of that container.
So if I do an L S I'll see all of the files that have been built inside of that image or again change
to the or seeing the container where I can change my root directory and prints out all the files and
folders inside of their and then if I want to exit I can hit command D I always smash commands or control
C out of habit but control or command D OK next comment.
Docker P.S. we can use this to print out information about all the containers that we are currently
running.
So for example if we start up a container in one terminal window and then open up a second terminal
window into a docker PSN there we'll see the idea of the running container.
The image it is using the command that was used to start it up.
How long ago he was created and so on.
Once a container is running we can also execute arbitrary commands inside of it.
So for example we could do a docker exact dash I.T. then put in the container I.D. and then the command
that we want to actually run inside there.
So for example if I wanted to start up a shell inside of my running post service right now I could take
that container I.D. I could do a docker exact dash I.T. within that I.D. And then once again run as
H.
And that will start up a shell inside that running container
and then finally one more very useful command is Docker logs.
This will printout all the logs that have been executed to be emitted by the primary process inside
of that container.
So for example if I flip back over I'm going to stop the running container
all then start it back up but I'm not going to override the default command.
So we'll do it a docker run even greater post.
And so as soon as I start this up our primary process which is that NPM start command is emitting some
different logs here over standard out.
That's everything we see right here.
I can get all that information printed out inside of a second terminal window by doing a docker.
P.S. getting the new container I.D. and then a docker logs and provide the relevant container I.D. and
that will essentially show me everything that primary process has emitted.
So again just some very basic commands we are going to be using these commands quite a bit.
And again we'll be running kind of variance of them in the Cuban 80s world in just a little bit as well
to just inspect what's going on inside of all of our different containers Well at this point we have
seen how to make use of Docker how to build an image.
We've made an image out of just the post service.
So let's take a quick pause right here.
When we come back the next video we're going to take that darker file and darker ignore.
And we're going to copy it over to all of our different other services as well.