1 00:00:04,530 --> 00:00:09,060 ‫For this assignment, I'm going to have you build your own image from a Dockerfile. 2 00:00:09,090 --> 00:00:13,980 ‫You're basically going to be going line-by-line in a Dockerfile and figuring out how to make it work 3 00:00:13,980 --> 00:00:15,330 ‫correctly on your own. 4 00:00:15,330 --> 00:00:17,710 ‫This is one of my favorite things to actually do in Docker. 5 00:00:17,940 --> 00:00:22,800 ‫I'm a little bit nerdy about it. I get kind of pumped up because creating a new Dockerfile from an existing 6 00:00:22,800 --> 00:00:28,200 ‫app, to me, feels like it's actually making the app better. Because I love the challenge of making something 7 00:00:28,200 --> 00:00:33,520 ‫that was previously complex, or inconsistent in its process, and becoming predictable and automated. 8 00:00:33,600 --> 00:00:35,910 ‫That's really what a Dockerfile is all about. 9 00:00:35,910 --> 00:00:41,670 ‫A common exercise for a Docker admin is to make custom images and help others make Dockerfiles for 10 00:00:41,670 --> 00:00:42,950 ‫their own source code. 11 00:00:42,960 --> 00:00:47,400 ‫Often, you'll need to go looking at the official images, and you may not know that much about the app 12 00:00:47,400 --> 00:00:51,590 ‫or even the language or packages it uses, but you still need to 'Dockerize' it. 13 00:00:51,720 --> 00:00:56,130 ‫Which is to say that you're making a Dockerfile for an existing app or service and you're getting it 14 00:00:56,130 --> 00:00:57,870 ‫to work properly in a container. 15 00:00:57,990 --> 00:01:03,660 ‫But, that process means you'll need to go searching for matching official images or one that's maybe 16 00:01:03,660 --> 00:01:05,730 ‫not official, but it's close to what you need 17 00:01:05,730 --> 00:01:11,160 ‫as you can get. And investigating that image repository, and the Dockerfiles in it, to understand how 18 00:01:11,160 --> 00:01:15,000 ‫it's built, and then how you can build from it, using the from command. 19 00:01:15,000 --> 00:01:20,910 ‫You'll need to learn the art of melding that existing image with your build instructions to get a fully 20 00:01:20,910 --> 00:01:22,590 ‫working image in the end. 21 00:01:23,230 --> 00:01:27,080 ‫In this one, we're going to take an existing Node.js app and Dockerize it. 22 00:01:27,250 --> 00:01:31,750 ‫Again, you don't actually have to know really anything about Node.js other than to say this is a 23 00:01:31,900 --> 00:01:36,130 ‫web app, and I'm going to give you some information, and you're going to need to create a Dockerfile from 24 00:01:36,130 --> 00:01:36,720 ‫it. 25 00:01:37,060 --> 00:01:41,680 ‫Really, the overview here is you're going to create a Dockerfile, and you're going to try to build 26 00:01:41,680 --> 00:01:46,630 ‫it. Then you're going to try to test it in a container. Then once you do that and get it working, 27 00:01:46,630 --> 00:01:51,310 ‫then you can push it up to Docker Hub. Then we're going to remove it locally. Then we're going 28 00:01:51,310 --> 00:01:57,400 ‫to run it again. Really expect, especially this build and testing part, to be iterative. 29 00:01:57,400 --> 00:02:01,140 ‫It's very rare for me to get a Dockerfile correct on the first shot. 30 00:02:01,390 --> 00:02:05,860 ‫Then I'll try to build it and I'll get a build error. Then I'll keep changing it and then build 31 00:02:05,860 --> 00:02:10,240 ‫it again until I get that to work and finish. Then I'll try a test in a container and it doesn't 32 00:02:10,240 --> 00:02:15,370 ‫always work the first time. So I'll have to go change in Dockerfile again, and rebuild it, and then create 33 00:02:15,370 --> 00:02:16,840 ‫another container from it. 34 00:02:16,840 --> 00:02:21,010 ‫So expect that process and you're going to learn tons just doing that on your own. 35 00:02:21,430 --> 00:02:25,840 ‫For this assignment, the actual file you're going to start with is in the Dockerfile assignment 1 36 00:02:25,870 --> 00:02:30,880 ‫directory, in the root of our repository that you downloaded from GitHub,the same one we've been 37 00:02:30,880 --> 00:02:36,070 ‫working with. And do note that we are going to use actually an official image, which means there's going 38 00:02:36,070 --> 00:02:41,080 ‫to be lots of good documentation around how to use it. And that includes the Dockerfile for the official 39 00:02:41,080 --> 00:02:41,840 ‫image. 40 00:02:41,950 --> 00:02:46,780 ‫If you remember me mentioning Alpine as a very small Linux distribution, that's the one I'd like 41 00:02:46,800 --> 00:02:51,880 ‫you to use here. You're going to use a specific version of Node that they will list on Docker Hub, which 42 00:02:51,880 --> 00:02:59,470 ‫is the 6.x version. You can use any of those options underneath the 6 branch. The expected test 43 00:02:59,470 --> 00:03:04,440 ‫result is that you're actually able to bring it up on your web browser locally, using the localhost. 44 00:03:05,020 --> 00:03:09,340 ‫Then once you get it working locally, you're going to actually tag it with a proper name so that 45 00:03:09,340 --> 00:03:14,640 ‫it's using your Docker Hub account name, and a new repo name that you can create on your own. You're 46 00:03:14,650 --> 00:03:18,340 ‫going to push it up to Docker Hub. Then once you've gone to Docker Hub and you've checked out 47 00:03:18,340 --> 00:03:23,350 ‫that it is there and looks correct, then remove the local image out of your cache, and we're going to run 48 00:03:23,350 --> 00:03:27,850 ‫the container one last time so that we'll actually re-download from Docker Hub, and then run it just 49 00:03:27,850 --> 00:03:31,520 ‫to make sure that everything is as expected. Just like other assignments, 50 00:03:31,540 --> 00:03:37,540 ‫if you get stuck, and it's OK if you do, remember that the next, following lecture is actually me going 51 00:03:37,540 --> 00:03:42,700 ‫through this assignment myself and how I might do it. Like other assignments, there's going to be 52 00:03:42,700 --> 00:03:47,800 ‫several options and ways to go about it, because again, this isn't an exact science. 53 00:03:47,800 --> 00:03:52,570 ‫Your Dockerfile might not look exactly the same as my Dockerfile, but if it builds correctly without 54 00:03:52,570 --> 00:03:57,520 ‫error, and then you get the website working on a web browser with localhost, then I would call that a 55 00:03:57,520 --> 00:03:58,300 ‫success. 56 00:03:58,570 --> 00:04:00,490 ‫Good luck and see you in the next lecture.