‫For this assignment, I'm going to have you build your own image from a Dockerfile.
‫You're basically going to be going line-by-line in a Dockerfile and figuring out how to make it work
‫correctly on your own.
‫This is one of my favorite things to actually do in Docker.
‫I'm a little bit nerdy about it. I get kind of pumped up because creating a new Dockerfile from an existing
‫app, to me, feels like it's actually making the app better. Because I love the challenge of making something
‫that was previously complex, or inconsistent in its process, and becoming predictable and automated.
‫That's really what a Dockerfile is all about.
‫A common exercise for a Docker admin is to make custom images and help others make Dockerfiles for
‫their own source code.
‫Often, you'll need to go looking at the official images, and you may not know that much about the app
‫or even the language or packages it uses, but you still need to 'Dockerize' it.
‫Which is to say that you're making a Dockerfile for an existing app or service and you're getting it
‫to work properly in a container.
‫But, that process means you'll need to go searching for matching official images or one that's maybe
‫not official, but it's close to what you need
‫as you can get. And investigating that image repository, and the Dockerfiles in it, to understand how
‫it's built, and then how you can build from it, using the from command.
‫You'll need to learn the art of melding that existing image with your build instructions to get a fully
‫working image in the end.
‫In this one, we're going to take an existing Node.js app and Dockerize it.
‫Again, you don't actually have to know really anything about Node.js other than to say this is a
‫web app, and I'm going to give you some information, and you're going to need to create a Dockerfile from
‫it.
‫Really, the overview here is you're going to create a Dockerfile, and you're going to try to build
‫it. Then you're going to try to test it in a container. Then once you do that and get it working,
‫then you can push it up to Docker Hub. Then we're going to remove it locally. Then we're going
‫to run it again. Really expect, especially this build and testing part, to be iterative.
‫It's very rare for me to get a Dockerfile correct on the first shot.
‫Then I'll try to build it and I'll get a build error. Then I'll keep changing it and then build
‫it again until I get that to work and finish. Then I'll try a test in a container and it doesn't
‫always work the first time. So I'll have to go change in Dockerfile again, and rebuild it, and then create
‫another container from it.
‫So expect that process and you're going to learn tons just doing that on your own.
‫For this assignment, the actual file you're going to start with is in the Dockerfile assignment 1
‫directory, in the root of our repository that you downloaded from GitHub,the same one we've been
‫working with. And do note that we are going to use actually an official image, which means there's going
‫to be lots of good documentation around how to use it. And that includes the Dockerfile for the official
‫image.
‫If you remember me mentioning Alpine as a very small Linux distribution, that's the one I'd like
‫you to use here. You're going to use a specific version of Node that they will list on Docker Hub, which
‫is the 6.x version. You can use any of those options underneath the 6 branch. The expected test
‫result is that you're actually able to bring it up on your web browser locally, using the localhost.
‫Then once you get it working locally, you're going to actually tag it with a proper name so that
‫it's using your Docker Hub account name, and a new repo name that you can create on your own. You're
‫going to push it up to Docker Hub. Then once you've gone to Docker Hub and you've checked out
‫that it is there and looks correct, then remove the local image out of your cache, and we're going to run
‫the container one last time so that we'll actually re-download from Docker Hub, and then run it just
‫to make sure that everything is as expected. Just like other assignments,
‫if you get stuck, and it's OK if you do, remember that the next, following lecture is actually me going
‫through this assignment myself and how I might do it. Like other assignments, there's going to be
‫several options and ways to go about it, because again, this isn't an exact science.
‫Your Dockerfile might not look exactly the same as my Dockerfile, but if it builds correctly without
‫error, and then you get the website working on a web browser with localhost, then I would call that a
‫success.
‫Good luck and see you in the next lecture.