Hey, welcome back.
In our previous lesson,
I showed you how to import WebGoat into an IDE.
You should have done that by now,
and if you haven't, please pause and go back and do that.
In this lesson, we're going to look at how to
run WebGoat in a Docker container.
This will prepare you for our practices
and other activities that will come,
as well as your final project.
There are several reasons you may want to
run WebGoat in a Docker container.
First, maybe your IDE doesn't support running
an application container and you're having issues.
You shouldn't invest a lot of
energy trying to get that to work.
We can simply run a Docker container
and run our WebGoat inside of it.
Another reason is maybe
your testing WebGoat in
our IDEs generally take up a lot of resources.
You don't want to invest those resources and simply
running an IDE that will be just in the background.
So we can simply run it inside of
a Docker container with slightly less overhead.
Or maybe you're not even using an IDE,
you could be simply using a text editor,
and you could be doing everything on the command line.
You can simply run Docker from there as well.
You may have other reasons for this, too.
This course is not about Docker,
and I'm not going to spend a lot of time
explaining the various aspects of Docker.
If you're interested in learning more about Docker,
there's good resources on Coursera and elsewhere.
But in this video, I will cover everything you need
to know about Docker to get this course going.
Okay, let's get into it.
So if you cloned
the GitHub repository from
the UC Davis repositories for WebGoats,
you would notice that you'll have a bunch of
script files and we simply go into that directory.
Now, in my original video,
I mentioned that we made
some modifications to some of these scripts,
specifically the addition of the build_run_webgoat.sh.
So if you simply run build_run_webgoat and hit enter,
this is going to call
the Maven commands to build the project.
I have disabled the tests for this, the unit tests.
So the reason for that is WebGoat developers
write unit tests to make sure that
their code is functioning properly.
Now, functioning properly is
an interesting concept for us
because the motive behind
WebGoat is to be an insecure web application.
But through our course, we're going to
be making it secure.
We're essentially breaking the functional tests
that the developer of WebGoat have written,
simply because their tests are
ensuring that we're breaking it,
that the code is vulnerable,
and we're simply breaking that by making sure that
our instance on WebGoat is not vulnerable.
So it's going to compile it,
and then it's going to create
a Docker container out of it.
It's going to launch our Docker container for us.
It should take about a minute or two.
If this is your first time doing it,
it might take a little bit longer and
that's why I wanted to talk over this bit of it,
and just show you how long
it takes and what screens to expect.
In future videos, we're just
going to fast-forward through those.
Just know that it says it started in 23 seconds.
It took a little bit longer
because this 23 seconds is the
referencing how long it
took to get the Docker container up,
not necessarily how long it took to build the code.
So at this step, we can simply go to our browser,
type in localhost:8080.
Now, just a small note about this 8080,
if you're running it in your IDE,
or if you have any other processes
that are using port 8080,
you might get a port conflict error in your command line.
So simply shut down
that process so that you don't run into that issue.
So if you go to localhost:8080/WebGoat,
you'll be presented with the login page.
I'll go ahead and log in with my username and password,
and you'll notice that it'll fail.
The reason for that is
the command that I wrote to bring this Docker up,
actually cleans up all the Docker volumes
related to this project every time it brings it up.
So you're essentially getting
a new workspace every time this comes up.
So we just need to simply
create our username and password.
Another thing to note is
the changes that we made in our IDE in
a previous video actually
come over in the Docker container as well.
So you could be making changes in your IDE or
using a text editor and simply use Docker to bring it up.
To end the Docker,
simply do Control-C on
your command prompt and you'll
be brought back to the scripts folder.
Now, you'll notice that these are.sh files.
If you're coming from a Mac or Linux background,
you'll know that.sh files are shell files,
and not something that'll run natively on Windows.
However, if you installed
the Unix tools on your Windows machine,
you'll also get all the facilities
that's required for this script to run.
So this build_run_webgoat script does
run on Windows if you've installed this tools.
If you haven't installed those tools with git,
simply open up the sh file and look at the command,
and you could write your own bat file
or simply just run those commands manually.
So I hope you got a sense of how to run Docker,
how to run WebGoat in a Docker in this video.
If in the future you have
questions about any parts of this,
come back to this video to get a refresher.