‫This lecture is the answers to the assignment lecture right before this one for managing multiple
‫containers.
‫This is basically just a recording of me thinking out loud and walking through the assignment. You
‫might have slightly different commands. That's OK as long as you got to the end result of the three
‫different containers, running the three different images, with the required parameters.
‫Here we go.
‫I'll probably want to run the MySQL one first.
‫mysql but I'm going to need to detach it and then open up port
‫3306. Then I'm going to give it a name called db. Then I'm also going to throw in this environment
‫variable.
‫That should do it.
‫Oh I have too many dashes on the e.
‫OK.
‫Now I shall do docker container log mysql.
‫Nope. Sorry. db
‫logs not log.
‫So I don't...let's see, I'm not sure...I don't see it yet.
‫I don't see the password.
‫It's pretty obvious.
‫Let me try it again.
‫There we go. Generated root password right there.
‫I want to copy that for later.
‫I don't actually need it for this assignment.
‫But that's how I would get the password if I needed to log into that MySQL server. All right. We're going to run
‫the next one -- docker container
‫run
‫detached
‫name
‫webserver
‫and then port.
‫It's going to be the Apache one so port 8080 on my host is going to go to 80 in my container. Then
‫httpd.
‫OK, and if I do a docker ps, both of those should be running. I can see on the right that their proper ports
‫are redirecting from my host into my container. That's what that little arrow means. Then, let's see one more
‫docker container run.
‫Give it a name of proxy. I'm going to have that listed on port 80 and forward to port 80. It's detached. And proper name.
‫OK I think that one's good. docker ps
‫You'll notice, by the way, that I'm typing docker ps, not docker container
‫ls
‫just because old habits die hard and the old command is docker
‫ps. But it still works. All right.
‫All three are running. All the ports are forwarding. Properly named them.
‫And
‫I'm actually going to...
‫I'm actually going to test their ports. If I do curl localhost,
‫it should give me back the nginx. If I curl...let's see localhost 8080, I should get back the Apache.
‫All right.
‫Those are open.
‫All right.
‫Now I need to clean them up. I want to do docker container
‫stop
‫Oh that's right.
‫I didn't name them that.
‫That's silly.
‫I'm just going to use tab to give me tab completion. I can do this one and this one.
‫Now.
‫OK.
‫All three are stopped. docker ps -a.
‫Yep.
‫All three of them. I could have also done docker container ls -a.
‫Same thing.
‫Now I need to remove them.
‫I'm going to do a
‫docker container rm.
‫I'm going to use tab completion again
‫and remove them.
‫docker ps -a...nothing there. docker images.
‫This is a new command actually. image ls. That shows me the three different images that are still there.
‫OK.
‫Everything's cleaned up. That's my assignment.