‫Let's get your hands dirty ‫for just a few minutes.
‫You're going to do some Docker commands to ‫run some basic applications with Docker.
‫And in order to do that, we have ‫a couple of set up requirements.
‫Now, in the next section, you're going ‫to learn about installing Docker on
‫your particular operating system, or ‫maybe on a server where you want to
‫run most of this course, but in this ‫video, before we do that, because
‫there's a process you have to go ‫through there's some reboots sometimes.
‫And before we do all that, let's ‫just use our browser and use a
‫free service from Docker to spin ‫up some containers on the internet.
‫This is play with Docker below me is mobi.
‫The Docker whale actually it's ‫Moby Dock is his full name.
‫He also has Molly Dock, which ‫you will see around who is a pink
‫whale, and we're going to use this.
‫It's actually labs.play with ‫docker.com, which has dashes in it.
‫And I'll put it right below.
‫Did you can see that.
‫So go to type that in, but in order ‫to log in there, you're going to
‫need to jump over to Docker Hub.
‫There's only really one account ‫with Docker and you need to go
‫over to hub that Docker dot com ‫to sign up for that free account.
‫Totally free allows you to.
‫Log in and upload images and open ‫source and do some things as well
‫as logging into play with Docker.
‫The only reason we need a login ‫to use play with Docker is just to
‫prevent people on the internet from ‫misusing the free service, because
‫this is why we can't have nice things.
‫So jump over to hub.docker.com.
‫Fill it out.
‫You really only need your email ‫address, a Docker ID or your username.
‫That's important because whenever ‫you're logging in, you're always
‫going to use your Docker ID and your ‫password, not your email address.
‫So fill that out.
‫Remember your ID and your password.
‫Jump back over to play ‫with Docker's website.
‫And you're going to sign ‫in with the login button.
‫So pause this video, go do all that ‫and come back here and push play.
‫All right.
‫Do you have your Docker ‫ID and your password?
‫You're going to be using that ‫throughout this course for various
‫things, but for now, we're going ‫to use it to log in, to play with.
‫And over on the labs.play ‫with Docker website.
‫When you scroll down to log in, if you've ‫logged in, you will see the start button
‫there, green not blue, you click that and ‫it whisks you away to an interface that
‫in the background is going to allow you ‫to spin up multiple Docker instances on
‫the internet using real cloud services.
‫That Docker is maintaining for us.
‫So if you click on add new ‫instance over here on the left,
‫right there, click on that.
‫And we're only going to create ‫one instance for now later in the
‫course, we can actually create ‫multiple ones set up a cluster.
‫Do all that.
‫The one thing you have to remember is ‫that these are timed out at four hours,
‫so you can only use the same instances ‫for four hours and then they just go away.
‫So if we create, add new instance and we ‫give it a minute for it to spin up a new
‫Docker engine on a VM, and it's going ‫to give us some information at the top,
‫the IP address, the SSH, and we're not ‫gonna really use any of that just yet.
‫We want to focus on is down at the ‫bottom and I'm gonna zoom in so
‫you can see easier when I'm doing.
‫Now, if we do a Docker ‫space version command here.
‫You're going to get back to things, ‫a whole bunch of details about the
‫client and a whole bunch of details ‫about the engine or the Docker server.
‫And Docker is a two-part system.
‫You're going to be using ‫something like that.
‫Docker command line client, like we ‫just typed Docker space version, and
‫you're gonna be talking to the Docker ‫engine over one or more protocols.
‫You might be using sockets by default.
‫There's also the TCP connection ‫that can also be TLS.
‫And then you can also use an SSH tunnel if ‫you're going over random internet as well.
‫The point here is, is that ‫the commands you type are in
‫a client that has a version.
‫And that binary is just ‫called Docker on window.
‫That's technically docker.exe.
‫If you're on the windows side ‫of things, but in Linux, it's
‫just called Docker binary.
‫And then it's talking to the ‫engine in the background.
‫That's going to execute through the API.
‫All these things were typing into it.
‫Now, back at our shell, if we type a new ‫command and you can type the word clear to
‫get rid of everything else in the screen ‫and put your cursor right back at the top.
‫But once you're up there, you ‫can type Docker space run.
‫Space dash D for detach, which means ‫we want it to run in the background
‫space dash P, which means open up ‫a port and publish it on my host
‫IP so I can access it remotely.
‫And we're going to run an Apache server.
‫So we're going to choose port ‫8800 to listen to on our host.
‫And then we're going to tell it to ‫go into the container where Apache
‫is running on the default port ‫80, that Apache is listening on.
‫Then we're going to type in the image.
‫We want to run httpd.
‫That's the name of the Apache ‫demon running in the background.
‫And if we hit enter a whole lot ‫of stuff is happening all at once.
‫We're actually downloading the layers ‫of the image, just like you previously
‫learned that makes up this full image.
‫Then it's going to create the ‫networking, create the virtual
‫interface for the IP address.
‫It's going to create the empty file ‫system, load all these files from
‫the image into that file system.
‫And then finally, once that is all ‫created, it will start the httpd process
‫in its own little namespace where ‫it's basically the only thing running.
‫Now, if we wanted to prove that that ‫thing's actually working, we could
‫curl the localhost of this machine ‫we're on because we're running this
‫container on this machine, and that's ‫also where our command line is.
‫So we could type curl to use HTTP to ‫show us the webpage and we could curl
‫localhost 8800 because that's the ‫port we told it to listen on, on the
‫host IPs, all the host IPs, including ‫the public one and the localhost one
‫. ‫And it works.
‫It responds with the ‫default Apache web page.
‫And we can even see that that container ‫is running with a new command Docker PS.
‫So that shows us a list of all ‫the container processes running.
‫And in this case we only have the one.
‫Now, there's definitely ‫a lot of magic there.
‫And I mentioned a few of the things ‫it does, but there's a whole lot more.
‫We'll learn a lot more about ‫that throughout this course,
‫but let's start another one.
‫What happens if we run multiple ‫Apache servers, we could even run
‫multiple Apache servers of different ‫versions, all with single commands.
‫And because of the isolation and how ‫Docker ensures that one app in its
‫own container doesn't see or effect ‫another app in another container, we
‫can run that same command as long as ‫we're using a separate public port.
‫So that 8800 port.
‫We have to follow the rules of IPs, right?
‫We cannot use the same port on more ‫than one application at the same time.
‫So while the container itself ‫gets its own private IP address,
‫that listens on port 80.
‫It's when we use the dash P we're ‫saying, listen, on the interface.
‫The actual interfaces of my Linux ‫host and for the traffic from the
‫particular port I'm telling you into ‫that container where the Apache lives.
‫So if I simply hit the up arrow a few ‫times and I back up and type 8801 slightly
‫different port, then it will launch ‫me a second Apache service of which I
‫can see if I type in Docker PS again.
‫I now get back two.
‫Now, if I had left that 8800, the same, ‫I would actually get back an error
‫saying that the port is already in use.
‫Now, if we get a visualization ‫of what we just did.
‫Remember earlier, we talked about the ‫Linux features of Docker running on top.
‫And then we have this image.
‫When you do the Docker run command, it ‫downloads the image for you automatically.
‫You could have done a Docker pull ‫manually, but Docker run also does that
‫for you if the image doesn't exist.
‫So it pulls that down for us, and ‫then it creates a new container.
‫When we typed that Docker run command.
‫So it creates container ‫one with the httpd image.
‫And then when we type it a second time, ‫it creates a another container container
‫two, with its unique ID, running that ‫same image in a different process
‫space that's isolated from the first.
‫Now when we publish those ports, ‫we see that port 80 is the
‫port inside of each container.
‫That's listening on the private ‫IP, assigned to each container.
‫That's unique.
‫That is only accessible inside ‫of Docker's virtual networking,
‫which we'll talk about later.
‫But when we do that dash P we're ‫saying, Hey, take this container
‫and forward any traffic on the ‫public port that I tell you about.
‫From the host IP into this ‫container, which is why we can
‫assign external port 8800 to forward ‫traffic inside of container one
‫and then 8801 traffic externally ‫will then come into container two.
‫now this may seem a little like magic or ‫certainly a lot of automation, but it's
‫really just focusing on major features ‫of Linux and now windows that are sort of
‫adopting a lot of these Linux concepts.
‫And you may have heard of a few of these ‫namespaces and cgroups I listed before.
‫Veths or virtual Ethernet devices.
‫IPTABLES is like a firewall and ‫general IP packet, routing and control
‫interface, and then union mounts, which ‫is something that we use for getting
‫the file system with all these layers in ‫it, into the container at start to look
‫like its own unique file system that's ‫isolated from the rest of the host.
‫It seems like it's a lot of fancy, but ‫when you log into a container, if you
‫were to just shell into one of them, ‫it would just look like a normal Linux
‫file system with a lot less in it.
‫All right, that's it for this lecture.
‫I just wanted to give you a taste ‫of what we're going to do later.
‫You can always use the ‫play with Docker service.
‫It should be available 24-7, but in future ‫videos, we're going to learn how to get
‫Docker installed locally or installing ‫it on a real Linux server of your own.
‫So we're going to have fun ‫with that later for now.
‫You can click close session in ‫the top left and that will shut
‫down the containers, free up the ‫resources for someone else to
‫use this wonderful free resource.
‫Thanks Docker.
‫See you soon.