 how to dockerize a PHP application. We are not here for how to dockerize a PHP application. The other sessions are on the right and left side. This is track three. Kai is a DevOps specialist who has deployed Docker in production for about a year now. In this tutorial, he will be providing a run through on how to dockerize a PHP application. And if he has time, with time, very sure he does. Very sure. He will show how to deploy an AWS and for CoreOS-based posts and tips and issues. And I think you're going to keep it very clear when we're discussing how to deploy and some of the issues that you'll be deploying. Hopefully, yeah, my goal is that hopefully one of you will dockerize your application. At least two hours. Yeah, and then I'll see you. Oh, I have a good nap. He's great at this, right? And he's really expert. So, to ask him any questions about Docker and how to dockerize your PHP with that, a round of applause for Kai. Thanks, Kai. All right. So, how should we begin here? I'll probably just tell you a little about me and why I think I'm an expert. I'm actually from South Africa. I'm 38 years old. I started on Windows. I started on Windows and then I started using Linux about, I don't know, 20 years, a long time ago. In fact, I studied at University of Helsinki hoping to meet Linus and caution on to the whole Linux movement. Unfortunately, he left by then, so it's just me and some other geeks. But I've been using Linux for a long time and Docker is very much a Linux technology. And since then I've been working for a whole bunch of companies. I've done Linux distributions and in my latest role, I've worked for a company called Spool which is a video streaming site aimed at Bollywood lovers, so Indian people usually. And we have a lot of users and yeah, we're rolling out Docker to production on Amazon platform. So I'll show you how we do that. And let's get started, I guess. Where's our last pointer? So yeah, I think Docker broke only into the scene like last year. So it's not really been around, it's not very mature, maybe. So it is a bit strange to talk about production and all that sort of stuff. But it's quite good technology and I'll tell you why. So yeah, I think this intro hopefully will take 30 minutes but it probably won't, probably be like 10 minutes. And then I prepare the Docker tutorial and if you go to this URL, you can have a look at the material. I'll just run by it one by one. I don't know anyway. And then I'm hoping we'll spend some time dockerizing your stuff. I mean, hopefully you all work on PHP applications and hopefully they could be benefit from being dockerized or containerized. And then as a bonus, I was gonna teach you how the company I work for is deploying Docker introduction. And of course, we have zillions of clients and a big requirement for us is that there's no dropped HTTP requests. So zero downtime. And if you have any questions about Docker, please let me know. Oh yeah, I run a couple of services in production. And yeah, I'm using, I'll get on to try the CI and all the rest of it, probably, hopefully. So what is Docker? I'm actually just made it up because I thought that'd be too easy to look at Wikipedia. So this is my definition. It's pretty much the de facto standard in containers. Who knows what a container is actually? You know what a container is? Oh God. A container is just like a service that's sort of packaged. That's the way I think about it. And the belief Docker was started by a company called DotCloud, a French company. Who's French here? I like French food. Don't usually like French people though. But anyway, DotCloud has got awesome. I mean, the Docker name is better than DotCloud, I think. And Docker is just a user interface on a Linux container technology, otherwise known as LXC. So what we're gonna do today is kind of silly in my opinion because you all who don't run Linux have to do virtualized Linux in order to get Docker working. So unfortunately, like in my workplace, there's a couple of people that use MacBook Airs and running Docker on a MacBook Air can be really, really slow. And I hope you guys have, who's running a MacBook Air here? Sorry, sorry about that. It's really slow on a MacBook Air, I'll tell you. And I mean, there's been solutions to like package things before I guess, but the container is like more of like the whole system. And a lot of people like, like when you think of Docker, they probably have like a picture of containers on a ship or something. I think that's a little bit of a strange way of thinking about it. Now I think of Docker being like the images themselves and the images as we all soon see are basically layered usually. And yeah, then I guess another thing about, usually containing technology is like for security, but I think Docker generally avoids the security aspect. Like I couldn't find any conclusive answers. I think no developer claims that it's really secure. I don't know, do you guys have any? I mean, so I don't think of Docker as like a security thing. I think it more of a distribution solution. I beg for someone else's silly opinion. Yep, that's what I said, that's what I said. So the three cool things about Docker is that first off the Docker file, it's like, and really like, it's like a make file. It's usually just a few lines long and it describes how your system is packaged. It's really quite nice. So I'll show you an example of that. And then another cool thing about Docker is that you can push images. So say you build your PHP e-commerce app at this particular version, you can push it to a repository and then you can have lots of services pull this image and deploy it. So that's really cool. And then the next major thing about Docker that I really like is the simple Docker run. So if you have a host that has Docker installed, you can just have Docker run and a few characters and you should be up and running on that service. And that alone makes Docker like really, really awesome. But hopefully I can show you that. By doing the tutorial, oh crap, my talk was like a lot less than 10 and a half now. I have some stupid thing. Anyone got an iPad Pro? This is my iPad Pro attempt. It's pretty awesome, isn't it? Can you see anything? I was hoping there would be a better board here. What else is, then hopefully let's do this tutorial first. Can everyone open that URL? Have you guys heard of GitHub? It's pretty awesome. Does everyone know how to use Git and clone down stuff? I don't know how technical you guys are. You gonna do the binos or something? What are you doing? Get in the echo. Okay, so I'm just gonna run through these Docker things with you guys and hopefully you'll be running it too. How should we do this to get you guys more interactive? Hopefully this won't be too boring. Okay, Docker tutorial. So this is the Docker tutorial. There's a brilliant readme. Oh shit, one thing. This is the readme file. You're supposed to read it. So have all of you guys got Docker installed? Who hasn't got Docker installed? Someone, who's got an old version of Docker installed? Are you guys playing Pokemon Go? Good idea. Is there anything around here? Okay, I'm, since you guys are so quiet, if you, okay, I'll say one more time, does anyone need some help installing Docker? Have you got Docker installed? Is everyone on the internet? Yeah. Okay, well hopefully if you don't have Docker installed maybe look over to someone else to do it. So I'm going to ask you to run some commands and these commands will install malware and make your computer completely owned by myself. So hopefully you'll join in. That's a joke, by the way. So let's start with the first thing. Oh, so if you run this command, right, it will pull down and run something. And what that runs will be a surprise. In fact, even if you're running malware, I don't think this would be a safe command to run in a Docker parlance because you're not binding, when you run it like this, it's running in isolation. You're not running it bound to your system yet. So even if you're running malware, this should be fine, I think. This should be fine. And if you haven't run this before, you'll see some different thing. You'll see it pull. Can I see someone playing along? Stop playing quick. Run this Docker run command, guys. Docker run abiosoft slash caddy codon php. So I think Docker images, usually like prefixed by company name of the service. And then this codon here and something else, that's a tag. Usually I think Docker has this concept of latest tag, but I usually like setting my tags. Okay, so, oh yeah. So basically if you haven't run this command before, what Docker does, it pulls down the image automatically. It's amazing. It's amazing. It's fabulous. It's fabulous. It's not a virus. I'll show you the virus later. So if you see the core graphics, which I can't show you because I pulled it before, what it does, it pulls down the image in each layer. And you're probably thinking like, why is it even layered? But then I'll show you why. I'll show you how. I'll show you later. But anyway, this actually doesn't work. And the reason why it doesn't really work is because we need to bind this port 2015. It's the year 2015, isn't it? We need to bind this port to our host and then it will work. So that's the second lesson of using Docker is you bind a port pretty much like this and then you can use the service. Unfortunately, every service has usually different ports, but you can usually figure it out pretty easily. So if everything really goes well, like really, really well, like I didn't screw up anything, you'll see something like this. We sort of PHP. It's not easy to use language with applications. But this web page and PHP instance is coming from the Docker command that we just ran. Oops, that one, yep, yep, yep, sorry. It's just gonna give us, whoa, that's awesome. So I think this is like the easiest way to install PHP. Like, who's ever installed PHP manually? It was like app Apache-PHP, app get install PHP, it's a nightmare. PHP, FPM, for this particular Docker image that I'm giving you an example of, it has everything contained in that one image. And then you're basically away. And yeah, that's, and the reason, yeah, the port is really important here. You have to explicitly bind the port, as I just did there, with minus P, switch. This is called a switch, I think, 2015, 2015. So this is the host port binding to the Docker port. So that's how it works. You bind your hosts to the container. Is everyone seeing something like this? Who's got to the stage? The most awesome stage ever. Okay. Oh, yeah. Oh, sure. Should we have the Docker version in one time? No, it shouldn't be necessary, but everything I'll teach you will be like Docker up to 0.8, or which Docker version do you have? 1.4, does that exist? Is Docker a game? That should be fine. Does the run command, I mean, does this command work for you? This Docker run minus P. It's not working? It's working. It's not working. What does it say? Does anyone, what's your name? Package 12.2, that's not Docker. Oh, yeah. Oh, sorry about that. Ubuntu use, you use Ubuntu? That's good. Package name's bad. Ubuntu is better to use gamba.bucker.com. It's more of a pocket-intensive stuff, but that gives you an install front source. Oh, okay. You have that option. I don't use Ubuntu packages. I don't even know. What the hell? Okay, well, I think I'll go slowly so you can probably catch up. So the cool thing about this is that I did talk about security, but this PHP is running in a container here. So if someone managed to hack this web application, it should only affect the container. And if you restart it, well, you can start easily again, basically. It's quite a good idea to run stuff in containers, just generally. So, yeah. Okay, next little thing. We can go through this again if you don't catch up. Yeah, I just wanted to show you that you could buy into different ports. So you can buy into 8080. I mean, typically if you're deploying Docker in production, you buy into 80. And then you get your load balancer to do the SSL and all the rest of it. So this is to show you it's not working anymore, then I'll just go 8080 and it's working again. Isn't that amazing? Docker so easy. Okay, so the next one. Okay, I want you to, when you do a Docker run, it actually does a pull before run if you don't have it. But I just wanted to show you what happens when a Docker pull is run manually. If the internet works, it should give you a char one sum, I think. And you can use that to track the particular image that you're using. So I use char one sums internally because I want to make sure that all the servers are running the same version. And that's how you do it. Okay, the next thing I want to show you guys is how to do environment variables. You usually have to use the environment variable when you're setting up, the thing that, the stuff that I deploy at work, I usually use environment variables to set up like all the credentials and that sort of stuff. And this is how easy it is to do, to set an environment variable. You just use this minus E switch. And I have to go back to, this one's stopped working, I have to go back to 2015. So that's how easy it is to push in an environment variable. The other environment variables that you get in Docker are pretty damn useless, like this hostname thing. I don't know what you can do with it. I haven't discovered what you can do with it. You can't do anything. Can you only add environment variables by the command line? You can specify a file. That's all right, the file will still work. I'll show you how that's done a bit later. But yeah, you can use the file or you, yeah, you just use minus E. So yeah, using environmental variables. So basically, I'm just trying to point out that using the Docker command line is pretty simple. There are lots of other switches like minus IT means interactive. And dash dash RM is an interesting one. Dash dash RM means remove the image once, sorry, remove the container once it's run. This is useful actually because sometimes you don't want the container, sometimes you want the container just to have like what's the term or temporary data. Sometimes you just don't want to save anything. And dash dash RM allows you to just nuke the service without touching anything on your system. Because if you don't run it with dash dash RM, you're gonna have lots of images left over. I'm gonna show you that a bit later. But the most important thing on this lesson here is the use of environment variables is really easy. Okay, what number are we on now? Cap five dot text. So, oh, when you run Docker, you can set a name. Yeah, when you run a container, you can actually make it stick around. And this is an example, just run it. Sorry, I should just go up. So in order to give it a name is just the dash dash name and this one's called change me. And then I'm also running the switch minus D which means run in the background. And minus P is of course that port stuff. So now I'm running this in the background. And then what, I find, I don't know if you guys have got better experience than I do, but I usually find that if I want to debug what's going on inside the running container. Oh, I haven't shown you how to see a running. This Docker PS shows you the running container. See, this one's up for 31 seconds. So what am I just gonna say? So in order to see what's going on in a running container, you usually have a shell available to you. And I usually just go inside that container running docker exec in the name of it. And then I can go something like, I can change something like go. Hello docker tutorial peeps. And then if I go back to the, I can actually change it in the container and debug in the container. But if you, but yeah, you have to make sure that your container sticks around. If you're keen on your data, otherwise usually I run with dash, dash, rm, everything's lost. But I think the point I'm trying to say is that you should try and make your containers good from the beginning. You don't want to go in and change anything. That's a really bad way of doing it. But this is good for debugging. So docker exec, good for debugging. So if I did something like, if I did something like docker, oh no, I'm not gonna show this to you. If I do like a docker, a docker stop change me, then the shell on the other side should die. Oops, oh, change me. See that on the other side, on that side where I had to exact the shell dies. So yeah, that's how you get inside your container and you fiddle around. Because one day you probably need to do that. What is the next thing? Okay, the next thing I wanted to show you is a volume mount. Who knows what a volume mount is? Okay, well, so yeah, a docker container has ideally everything encapsulated in it. But you should only think of the thing of the stuff that you wanna encapsulate is the service. And usually a service requires data. The usual way that people do this is using, if they want data, they use a database like MySQL or memoryDB and they make some sort of network connection to their data store. But I'm a bit old school and I like to use flat files. So the way you do that in the docker world is that you bind a directory, an absolute path. Is that the correct term? Yeah, and then you bind an absolute path from your host to the relevant part in your container. So in this particular container example that I'm using, Abio SoftCaddy, the index file is in SRV. So what I can do here in this example that I'm hoping to show you is that I bind the source directory into SRV and then I can change things and have persistence and use all my development tools on my host or something like that to fiddle around. But the only thing that's common between these two things would be that directory. So let's try that out. Will this work? Okay, so back here. So now I bound the SRV, the source directory here. Okay, so what can I do here? Hello docker tutorial people. Again, I have nothing more to add than that. Yeah, so the cool thing about this is that you can kill the container. What did I call? Stop and mount me. So that container will be dead, but the index will still be there. And if I run the command again, well I have to, I have to RM it I think. And then I can, oh, what have I done? Oh yeah, you're right. I'm in the wrong directory. You keep your tint, brown biscuit for you. Okay, so yeah, here we go. Ta-da! So yeah, you can kill your container. You can bring it back, your logic is there. But you shouldn't really be using that for source unless you're developing. I use it for my data and my applications. But you know, do what you like with Docker I guess. Make your own mistakes. Okay, so that was that lesson. Are we on seven? We're going really quickly, oh my God. Does anyone want to break? I want to break. Okay, I was just putting it, I think I was just putting it together for you guys here. Because if you were, oh, what have I done wrong? Mom, he's the running. Yeah. So the commands are quite simple. Stop to stop the container. RM to delete it. This is why you should be using dash dash RM. So the cool thing about dash dash RM is that you can break and run it again. Because what happened was the image was removed. Okay, so I'm just putting it together here again. And in this case, I'm using the environment variable which I love to do into my index, my source to index our PHP. Sweet. So yeah, now I think most of you who have an application, hopefully just have it sitting on some directory, right? And in a sense, you can dockerize your application or begin to dockerize your application with just this one line. Boom, you can go to your boss. I've done it. I've done it, boss. That's how you pretty much docker, you begin to dockerize your own application. I think hopefully we'll go through your stuff in more detail. But that's pretty much how you get started. Okay, let's go on to the next lesson. What are we on now? Is it eight? Oh, okay, now we're getting onto the beef, guys. We're getting onto the beef. This is where the swim things get real. Now we're gonna do a build. So that's a, this is a very basic docker file. And my plea to all of you is keep your docker file simple. Don't like try to impress anybody by making it complicated. The simplest docker files are the best docker files, in my opinion. And all this docker file is doing is using that particular container which already has a PHP and a web server inside it. All it's doing is adding the source directory, which I'm assuming in my case here is where my index.php resides and putting it into the containers directory, which is SRV, and it creates the image. So let me show you how that's done. It's as simple as doing this. You run docker build minus t to give it a name or is it a tag? Who knows? I don't. And when you build, it can be really quite quick too because docker has like an intelligent build system. So it knows that the base container which you're from in here hasn't changed. And it also kind of knows maybe that your source directory hasn't changed. So the docker builds happen real quick, real quick. Has anyone used the AMIs on Amazon? Building an AMI, slow. Building a docker image real fast. Especially if you've got the layers around. I guess if I change the source right now, like I just changed it, like fixed. Fixed it. I think it should realize that you can see here that it hasn't used the cache. See there, use the cache here. Hey, no, do you use the cache? Why? Because it realized that I changed something in source. It's so clever. I love clever technology. It's like Makefiles. Who uses Makefiles here? Makefiles are for pros. I love Makefiles, but no one knows how to use a tab, character properly. So that's the reason why they've fallen out of favor. So yeah, what did I do there? I created a docker image, and that has everything inside it. And if I run docker images, it should show you all the images I've ever built and the last one is on top. So you can see I use docker all the time. Why has, okay, sorry about the formatting there. You can see, oh right, you can't really, but the image is 84 megabytes. I think it's quite small. And the reason why it's quite small is because my from image is quite small to begin with. I'll show you that a bit later. But yeah, you can see every time you build an image, you get a particular image ID. Ideally, you tag it. I'm not just showing my tags gone, or name, or rather, you name it as I did there. Don't be an idiot and don't name it like I did here. So that's, this is basically how, this is the means of docker right here, your images. So I created an image, I think, and now all this left is just to run it. And I'm sure it works because I spent my Sunday checking this worked. Okay, so yeah. So there's no volume mounts. I basically put my source code into this PHP, HTTP thing, and I'm running it. So that is pretty much how you dockerize your PHP application. Of course, you guys are probably using Nginx and Apache or some other different version of PHP. All of those different scenarios can be addressed. You just need to ask me. I like using Caddy. Who's heard of Caddy web server, by the way? Anyone? The reason why I like Caddy is because it gives you SSL for free, and the configuration's very easy. No one uses Caddy? You guys are missing out. It's like the new docker, guys. You heard it here first. Okay, so yeah, that's how easy it is to make a dockerize thing, guys. What's the last lesson here? Oh, yeah, I thought you guys might say, but I don't want to use Caddy. I want to use Apache, just like we do at work. So, with this command, this fancy ask command, what, is it still running? With this command, I'm actually using the official PHP docker image by PHP Foundation or something. And this is how easy it is to get running. So this is running the official PHP image. And all I had to do, I mean, I pulled it already before you guys, is basically just use a different image thing. And it automatically pulls it down and runs it. So you don't have to trust my Caddy image. You can trust PHP. And if you go to the docker hub, you can see what images are available. You probably don't want to use my image because you can't trust me. I'm just some bozoing. This is embarrassing himself in front of you guys. No, oh, is this the PHP one? Where's the PHP one? Okay, so PHP has an official repository. So docker hub is a remote place where images can get pushed to. You can use different places to push your image. You can have your own image server, which I do at work. Because all of our stuff is private, proprietary code, and everyone knows that proprietary code is so much better than open source. Everyone knows that. So it's not about saving myself from embarrassment. Anyway, so this is the PHP repository. And you'll find that different projects, I think like Nginx and, I don't know, there's lots of different projects on docker hub. It's kind of like the GitHub for images. You can see that PHP Foundation supply all these different flavors of docker images. Who uses PHP 7 here? Hate you. Docker, PHP 5 is where it's at guys. Who's using PHP 5? Five alive. I think there's some fives here. To be honest, I don't use these images, but I think professionally speaking, if I was deploying PHP in production, I'd probably use these things. Because I'm one of these believers that upstream should know best. I actually don't like a lot of Linux distributions in the sense that they make their own like build flag tweaks to packages. I think that's kind of bored. Upstream should make these sort of decisions and maintain the whole life cycle and all that stuff. So as you can see, they give like the CLI version. I don't know why you would use PHP on the CLI. Who does that? This is the Alpine version, which I really recommend. Alpine is basically, instead of using the fat lib C of Ubuntu, they use a much smaller lib C based on this new lib C cord muscle. So I recommend Alpine. Apache, Apache is a web server, isn't it? Or it's a tribe. They got wiped out by the white man. Is that right? It's no, it's a web server. It's a web server, sure it is. I don't use Apache. Who uses Apache nowadays? I think Nginx is a lot better, isn't it? Yes. FBM for you guys who don't know is like the, I don't know how to explain it. It's like the proxy thing that talks through the web server. Yeah, what is ZTS? Does anyone know? I don't even know what ZTS is. The sound threads. What? Threads. What does that mean? Okay, you can give a talk about that later. Okay, then we have the PHP 5. Okay, so I want to say here at this point that there's different ways of deploying PHP. Some people actually deploy PHP in Docker containers. They have one container for the PHP FPM and then they have another container for the web server and then they link them up. But I think that's a little bit over-engineered. I like to have everything just together. Like, this is the service. And yeah, that's just about as interesting as PHP is. PHP images are, sorry. Does anyone else use a different PHP image out of interest? Keep going in the front. To be honest, I think that these images focus a little bit too much on the CLI. I mean, who uses PHP on the CLI? That's crazy. You? You, anyone? Yeah, there's too much of a focus of that. This is more realistic. It's pretty much like my example. Oh, you do unit tests. What are they? I'm joking, I'm joking. I know they are. There's no, there's a token that you use on the CLI. Okay, I know where you'd use the CLI. PHP minus L. Okay, so, you might wanna override the PHP.ini if you're crazy and saw some extensions if you're nuts. So yeah, I think this is a more, maybe this is a more realistic example of a Docker file. I think that someone's installing some JPEG conversion stuff, but it's full file. What is PECL? Who knows what PECL is? Peckle. Yeah, it's PECL, you're right. Okay. Yeah, and as my example shows you, you can just run it like this. But I must say that the official images, that they're huge, like, let's have a look at the sizes here. Docker images. Grep Apache. It's 404 megabytes. I think the images that I usually use are 80 megabytes. And I think it's a good idea to keep them small because if you get onto Amazon deployment, when you wanna scale your service to millions of users, the way to do that is to support a new instance and pull the image. And you want to do that in, like, as least time as possible. If you're pulling like a huge image, it takes time. So if the image is like 40 megabytes, the image is pulled, run, and you're away, serving your spike in demand. Okay, I think that's pretty much the basics done. Did everyone kind of get that? Did you manage to install the real Docker? Did you run some of these commands? Do you have a virus now? No, don't. Safe. So, yeah, that's basically what I wanted to show you guys. There's some more advanced stuff here. Let's start with the, okay, this is slightly more advanced. This will only work in the very, very, very latest Docker, 1.12 or something like that. And using those lines, you can basically embed an environment variable at build time. It's just a new feature that's come out with the latest Docker. And why would you want to embed environment variable with your Git version? Why would you want to do that? So you know what the hell you're deploying. It's really quite useful, it's a little tip. So basically, in your PHP code, you just echo out this commit variable and it tells you the version of your source code. So basically, if we do a scale event at work, I can just have a look at the bottom of the, on the footer where people don't look or have to scroll down to and I can see you're running the right version. And that's how you do it. I can just run those commands for something to do. So Git describe tells you what the current version is, BDE, whatever, build it, build it. You see that's how you expose the version in the image. And as far as, I'm just going to drink this because I'm thirsty. If someone has a better idea about embedding versions, does that took me ages to figure out? This took me ages to figure out. What I just showed you here is going to save you maybe half an hour max, but it took me a long time to figure this out. The other more advanced thing I want you to show you is Composer. Who uses Composer? Hardly anyone. No, about four or five people. To be honest, I don't think you should use Composer because that means you're going to become the next Node.js junkies and start using a thousand million dependencies. Dependencies are bad people. But no, I, you do, you do need to use dependencies sometimes. Like PHP. So in this example, I'm not sure, if anyone has any particular questions, we can go through them. Well, in this example, I am showing how the caddy server is installed, but also that the Composer is installed, and then importantly, importantly, there's a line saying what your dependencies are. You can use the Compose.json in your source directory. You can do it that way, but I prefer to do it this way because it's more explicit. And another important thing, when you're constructing your Docker file, it's important to have the dependency added before you add the source because I find that there's some sort of, what do you call it, some ordering problems. Like you don't want your source to come before the SDK download because if you change your source, you probably will trigger the Compose to run again. And installing the Amazon SDK takes like five minutes. So this is how you get running with Compose. So in this, I don't know, 35 lines of code, I've kind of described quite a complex system. I mean, if you're using Amazon SDK, your app is probably pretty hardcore. They're ready. And okay, we could look at the Docker file for the Apache or Nginx one, which will be a bit more complicated, but I kind of like how simple this one is. Like you, another thing you do in a Docker file is that you expose the ports that you're going to use. WorkDoor just means that keep everything in that present working directory, set that as the present working directory. The entry point and command stuff is a little bit complicated. You basically, it tells the Docker image what is the default binary to run. And you can actually override that, which is pretty sweet. Otherwise, I think it's all quite simple. This APK is just the package manager of Alpine. You know, running curl, which is probably a bad way to install something, but at least it's over 80, yes. This is how you write to a file. This is what I think makes Docker really successful. Is this Docker file? It's really, really simple. I think it's simple. Anyone have any questions about this? I mean, usually you just do it from, and you don't even have to do the stuff. Someone is cleverer than I am, pretty much did that stuff. But this is how you define a whole service, which is so nice. And, oh, I don't think I have the energy to run through this example, but this example here shows you how to set up, how to, I think on this example, this took me way too long to figure out last night. Who uses the Amazon SDK? Who's ever designed it? It's like really hard to use. It's like factory, constructor, all this thing does is send an email. You know, this reminds me. The reason why I got into PHP years and years ago is because it was simple. Remember the good old days, guys? Remember the good old days? Oh my God, this documentation, it's sweet. It runs, then they just make, then they just screwed it up, didn't they? Then they loaded fonts. Then they added object-orientated code. Object-orientated code, hate that stuff. And then most APIs now have really complex constructors and things like that. But look at this, it just returns a billion. You just read it, it's just one line. Now look at what we have. This is an amazing advancing technology. Well, to be honest, Docker is a good advancing technology. This is bullshit. Just know the difference, okay? Just trust me here. Good, bad. Good, bad, good, bad, good, bad. Yeah. I spent hours on that yesterday. Okay, yeah, I don't have the energy to show you my Amazon ID right now. Yeah, I would have to expose my Amazon ID if I'm gonna get this working. But it does work. But I'm not that dumb to show you my ID in here. No way, guys. No ways. You're gonna hack my email. So, oh God, is that two hours ready? Just one hour. I think let's take a break. And after that, I was, I know that there's not much space here, but I wanted to actually look at everyone's project, steal the code, sell the code, and retire. But no, I wanted just to see what you guys are developing and help you dockerize it. I mean, hopefully we can do that. And at the same time, go to toilet, get a drink. There's actually a beer tap over there. If you can drink beer, get me one. But yeah, I think the rest of the session, I just wanted to go through the stuff again, help you dockerize your app. Because once it's dockerized, it's gonna be super easy to deploy. And if I get, once I've rested, then I'll show you how I deploy on Amazon. And it's like, it's fast. And it scales. And it's what you guys should be using too. Using the ECS CLI. I don't know if you've heard of it. Okay, thank God, that was, that was painful. So using the power of Apple Pro and a pencil, I created this monstrosity. To be honest, docker has a huge community. You're gonna find, if you just Google the stuff, you'll find all sorts of cool stuff. But I thought I'd be really cool by just making some original content. So yeah, this is what I wanted to express. You can get, image stores can be for Amazon ECR. If you want to private, you can use docker hub, push pull. You can build into your local images or you can push out through Travis. Hey, who's using Travis? I didn't even get on to that. Anyone using Travis or Circle CLI or? Drop. Drop. Drop. Drop. John. Drop. Drop. DRLM. Yes, drop. Never heard of that one. It is docker rising. Yeah. Oh, it's a docker one. Oh, okay. CLI is a wonderful thing to waste a lot of time. But I can show you the way, if you guys are interested, I can show you how I made my pipeline that builds the docker image and it installs our docker hub or something like that. And then obviously, once you have the image on your machine, and then you run the container. And the Brazilian guy, Daniel. Brazilian guy. How many gold medals do you guys get? Command. With the gold medals, I think six. It's nothing compared to England. No, yes. Number two in the world. Heard of it? It's called Great Britain. Recently he became independent from Europe. Almost. Yeah. Are we all back yet? When you shoot the containers to production, the code is like, and you capture a little bit of the part of the content. Yes, yes. The code is in the container. And usually the way it works is that you specify in an environment variable what your database stuff is. So if anyone's using Travis, here's an example of how we, so what happens? Okay, this is just like a manufactured example, but you do it, you do a good push, and then in this case, you guys probably all have proprietary code, because proprietary code is a lot better than open source code, as I mentioned before. But in this case, this is how we push to Amazon Container Store, which is private, because our code is private. And obviously some of the assets are private too. So yeah, if anyone, you guys can feel free to email me or whatever, I can show you how my pipeline works. How my pipeline works, and then with Travis you can embed the secure keys. Actually haven't finished my presentation. Okay, I'm gonna resume because I don't know what else to do. So who did that thing? Yeah, I have this horrible graphic. I'm sorry guys, I'm sorry. I think of containers more like bricks than 40 foot containers on the back of a ship, because usually they need to be linked up or something like that. As I mean, I talked about this before, but in my example I kept it simple by having PHP in the web server in one container. Danielle was saying that he, at your workplace, he used PHP linked with the web server. That might be a bit better. And then obviously you'd probably link to another container running your database. That's how you do it. And you would keep everything same using Docker compose, which I'll make show you a bit later. Or you could have everything running in one container. I don't know, it's up to you guys. This is up for debate. I was gonna mention there's a limitation with EC2 in the way memory works, but ideally the cool thing about Docker, it's sort of, in the Northeast you had VMware, where the isolation, you said how much memory that VMware is gonna get. The cool thing about Docker is that the virtualization is a lot lighter weight. It's like it's a native Linux feature. And you use the resources of that bare metal machine a lot more efficiently, and you can share the memory a lot more efficiently. So don't run Docker on VMware, unless you're crazy. Don't do that. So the important thing about using Docker in production is the pipeline. If anyone uses, what do you call it? CI, the CI sample, do this integration. If anyone uses CI, you might know that it's quite slow. Once you do a git push, a Travis build can take like 10 minutes, because what Travis does is it itself, Travis is a Docker company, I guess. I think it sets up a container, grabs your source code and builds it. But that can take a long time. So doing a whole, like say there's a stupid mistake in the production server. Like, CI, we need to change this now, otherwise our service will be gonna lose a million bucks. Doing it this way is kind of slow. What I usually do is like, just build that locally and then I might just push it. I push it to a machine or something and then I'm running it. Well, I push it to my ECR rather and then I'm running it. And this approach, this sort of, this is usually the steps that I usually use. Because CI is for people who've got time on their hands. But if I'm doing something quick, I use this. If I'm a bit more casual, I use this approach. So this is how you do it. Yeah, this is a very boring thing, but I think it's worth talking about. Unless you know all the negative sides of something, then you're probably not an expert on it or something like that. Well, not to say that, I mean, am I an expert? I am, in this case. But there's, with Docker, I think some guy, oh, you mentioned it before, with the Docker world, the minute you get into Docker and you maybe search like Docker production, let's do that. What kind of crazy results will we get? Amon. Anyway, I wanted to basically say there's lots of companies offering enterprise solutions for Docker. And the ones that I've seen are viciously complicated. And even like digital, who uses digital ocean here? Like lately they've been pushing the whole clustering concept. I think that's really overkill. I highly recommend you just like, just use, just run one container with a load balancer. That's seriously all you need. You don't need to use Kubernetes. You don't need to run Swarm and, I don't know, do crazy ass things with your Docker image. Just keep it simple is what I have to say. But unfortunately, even like Docker, the company itself are pushing Docker cloud and the rest of it, which offers an abstraction over Amazon and some other hosting services. I just find it just really silly way of solving problems. It's just these abstractions that they're doing makes things so complicated. Another thing I don't like about this new way of running services, the Docker way, is that you don't have access to a full host. Typically you don't have Chrome and Chrome is like to run time jobs. I find it difficult to run time jobs in the Docker world. I mean, there's different solutions. You probably have your own way. Who has a great solution for running time jobs on a cut down host? You do. Anyway, I find it difficult. There's no fantastic solutions for logging. Okay, I think at work we use something that was set up by somebody else like Kibana and Elasticsearch, about 40 gigabytes of code just to be able to century log some stuff. Anyway, the logging solutions are not very easy to use. I personally, on my personal stuff, I'm beginning to use a CoreOS SystemD logging. Who used the SystemD here? One person, two people. Anyway, I'm using SystemD for logging on a personal level. It's gonna take me ages to convince my colleagues to go to SystemD because SystemD isn't really well supported on a server operating system, is it? Ubuntu has really crappy support for SystemD, but I think CoreOS has got good support. I don't mind that. Yeah, there's lots of container solutions out there. Like, SystemD has its own container solution, but Docker, the good news is Docker is pretty much the de facto standard. Another mistake, as I mentioned before, like Docker is somehow cleverly isolating and sharing your resources. So running Docker on top of EC2, I dare say, I know I'm in the Amazon office. It's kind of crazy. But ideally you can run Docker on bare metal. Obviously Docker requires Linux. And I'm a big Linux fan, but let's be honest, Linux is like a billion lines of code nowadays. It's not the same project that was back in the 90s or something like that. It's really, really, really complex. Sometimes I think Linux is just too bloated nowadays and I should be using BSD or live in a cave or something, just get away from all. Linux is really complicated. But the cool thing is that Linux is so much better than that crap you all use Mac OS. And running Docker on top of Mac OS is kind of nuts because you're having to run some sort of virtual box or virtual layer. So as I mentioned in the beginning, yeah, my colleagues who are using Mac OS and Docker, they're like, oh, kind, this is slow. Is this really better? Is Docker really better? Run it on my machine. It is blazing fast. On Mac OS, it is really, really slow. Another thing to watch out for is volume mounts. I gave you an example earlier, but there are many tricky things about volume mounts, actually. Many tricky things like volume mounts. Like for example, you've got to be careful like when you install things into the volume mount, they will probably, like Docker doesn't actually allow you to install things into Docker mounts. And then there's like permission problems with volume mounts. Anyway, volume mounts. They look simple. In practice, you might get burnt. Docker housekeeping is another issue I've run into. You guys might have some good solutions here, but like if I go Docker PS-Manus A, oh, this is on my, okay, that's on a different host. I mean, I run lots of Docker images and I don't, oh, these are my containers. These are my, I run a lot of tests and basically you get, if you don't clean up after yourself, you get a lot of cruft. And it's not such a big problem here because I think all of my stuff is like quite small. But we've had at least one case in a production server were going like, hmm, why is this production server running out of space? This is strange. But what was happening was Docker images were taking up space. So something to watch out for. Um, da, da, da, da, da. Oh yeah, the first question I had when I started using Docker was like, where's your, where's your, how do you do virtual hosting? How can you have a web hosting technology without a virtual hosting or load balancer? Where's that? Where's load balancer? Where's a virtual host? Where's the load balancer? That's all the questions I was asking. But yeah, Docker doesn't have really great solutions for that. There's many ways you can address the problem, but in my experience at work and things like that, I use the, I know it sounds a bit of a cop out, but the Amazon load balancer is extremely good. And it works really well. So you use that one. And it also gives you SSL and things like that. But you could, you could, you could obviously run HA proxy in another container, but I think that also makes kind of things kind of complicated. And it's, it's best actually if your load balancer is on a separate instance. So yeah, these are the things you should watch out for. Yeah. I think that's my tool here. So does anyone want to like need some help, like dockerizing their app or something? Or just use me guys. Use me. Use me and abuse me. Is that a dot and what? Pardon? Is that a dot and what? Using the other best is CS. Oh yeah. Okay, I can show you that. I can show you that. Yeah, I can show you that. Yep. Yep. I can show you that. Amazon. Okay. Actually, I have this weird problem where I can't see when I'm tapping. Oh, okay. Who uses Amazon anyway? Out of interest. Five. All of you, I guess. Well, you, actually, let's be diplomatic here and show you how I do it on digital motion today. Okay guys, don't hack me. Please don't hack me. I'm going to show you digital motion, but in all honesty, close your eyes. Shit, I'm too slow. Okay, so to do it on digital motion, forget it, no. Yeah, to do it on digital motion, I use CoreOS. What are these other ones here? I use CoreOS. And yeah, for those who don't know what CoreOS is, you get, you associate with Docker to CoreOS and it's like pretty much nothing there. Okay, you have like your home directory, but there's nothing installed and except Docker and you basically just go Docker run and you set up services with a service file that looks something like this. It's just a deservice file. So this is how I roll it out on CoreOS. And CoreOS is actually quite sweet because it auto-updates and randomly reboots your computer, which sounds terrible, but it's actually quite good. So what happens when you run in CoreOS is it updates itself and then it has some weird algorithm and then it reboots your machine, but this indeed restarts the service and makes it all work. So this is how I run it on CoreOS. And I recommend perhaps using CoreOS before using Amazon Container Service because the Amazon Container Service is quite complicated. It's like, you know how Amazon is, like renames every technology in their own terminology just to make you really confused. It's not a VPS anymore, it's an EC2. It's not a web server file anymore. It's an S3 object or something like that. So it's really, really confusing. So I really recommend running CoreOS and you can run CoreOS on EC2 too. In fact, if you've got an old computer laying around the house, it's still CoreOS, familiarizes yourself with system D. It's very good technologies. So basically the way I set up a CoreOS machine is that I basically spawn it, then SCP the service file and then I enable and start the service file. That's all you do, I think. That's all you do because in the service file you see this exact start pre, it actually pulls the image down. And runs it. Everything is contained in the service file. Everything, I think. Except maybe I have to copy in some, forget the stuff I have to copy in. But everything's in here. I am syncing the data. Another cool thing about this is that as I mentioned CoreOS updates the OS and then reboots the machine. So everything's security patch. But also when the machine gets restarted, it does a docker pull. So if I update this image that I have, it gets updated. So this is like a fantastic approach to maintain lots of machines without any effort. I mean, anyone who has the SH into a machine does that get update and it just upgrade. You're doing it the old way, guys. This is the new way. So yeah, the CoreOS and now I'm gonna show you Amazon. Oh my God, this is scary. Guys, you cannot get my password here. Please, please, don't get it. Okay, wait, I got a, I can't do this. Sorry, I need to figure out a way to mirror the screen. Okay, I think you can see what I've seen. Amazon, Amazon. Oh my God, she's been using Alibaba Cloud. Oh my God, it's really bad. I thought it makes Amazon look really, really good. Okay, guys, close your eyes. You know how this works. Quick advertisement, because I am, what do you call it, attention seeking junkie. I have a YouTube channel and I usually, some of the videos are about how to, yeah. This is a video about a ship. No, you don't need a website. You don't need a website. So I have a YouTube channel. It's amazing and you should subscribe. But the reason why you should subscribe because I actually, I'm gonna do what I'm gonna do here but I took a video of it earlier. So if I screw what I'm gonna do up here now, you can just watch this video. And in this video, I use a program called HTTP ping to prove to you guys that the Amazon load balancer doesn't drop a single request. But I did notice that when it does a transition, and sometimes it can be a bit, the latency can be quite high. But besides that, I chat about really interesting things like where to buy lightning cables and things like that. It's not just about stuff like that. I think I also talk about CoreOS and all sorts of stuff. I've even got my wedding. Don't watch that. Yeah, so please subscribe if you're interested. And if you have any requests, I can make a video maybe. Okay, so let's get, let's have a quick dive into Amazon. Amazon, Amazon, so I dare say, it's not just because I'm here and I'm eating their food. Amazon is the best platform to roll out a production service, I'd say. Really it is the best. And Amazon have a couple of projects that make, they're quite new actually, and they're all like, I don't know, zero point something versions, but they actually do work. But it just takes some time to get familiar with it. So Amazon have their own Docker Optimize images to deploy Docker images to and run them. And ECS agent orchestrates this stuff. And the tricky stuff is when you, is orchestration when you want to roll out a new version. Because usually what happens is you have two instances running, they both have the old version. You want to take down one of them, put it in the new version. If that, if that stabilizes, then you want to put it in the other new version. So you both have the new version. So this is what the agent's for. And this ECS CLI, you can actually do everything through this container service. Web interface, but I prefer to use, I prefer to use this because it's faster. I think it's faster, it is faster. So this is the Amazon EC2 service. Who's using this by the way? One person, okay. So yeah. I'm going to start from scratch here I guess. Let me just think how I'm going to do this because I don't want to show you my key. This is really tricky. We don't need to do distance, it's okay. Pardon? Is it a distance running Amazon or not? We don't have to show you the key. Let's meet up with the Rosin. All right, let's just go for it. Get started. I don't know, I don't know. Okay, let's just, what? That's that. Okay, so Amazon provided a whole bunch of services, but most of you guys probably have proprietary code. And a big part of Docker, as I tried to explain earlier, is that you need to store the images somewhere so that your new machines can take the image and run them. So in the Amazon terminology, this is called EC2 container registry. I don't know why they call that that. But the Docker version is called Docker Hub. And I think Docker Hub have a private repository too. And you can use Docker Hub or you can use EC2 container registry. But I know EC2 container registry is probably the better choice because I'm running out, I'm deploying on EC2 instances. I need the container registry to be fast. And there's one in Singapore. Just recently they launched in Singapore. So guys, I mean, there's alternatives, but I can tell you which one's the best through my own experience. So basically here, I set up a repository that God knows what that should... Can you see what I'm highlighting? God knows what that means. But let's find, let's deploy an application, right? Okay, perfect tutorial. Which one did I build last? PHP tutorial. This works. This would be amazing. Okay, so this is what I'm gonna try to deploy an Amazon infrastructure now. Hopefully, hopefully this is gonna work. Okay. Close your eyes, guys, close your eyes. I built it too. So it's this easy to set up a private image store. Oh shit. Oh, you can't just create one. Okay, I'll have to tag it. Okay, I should just follow the instructions, shouldn't I? I think it's a bit fussy about the name. Let me just run it just to make sure it's not crazy. Okay, that's fine. Okay, make life easy and run what the name. Tag it, push it. So in production, I usually tag things with the git revision numbers. And that way I know exactly which image I'm running. I use everything around git short hashes. So as you can see, it's quite fast, but this is only 80 megabytes. And as you can see, it's pushing in layers. So the cool thing is it's, if I change something small here, it should just push one layer. So let's change something small. Something small. If I build that again, oh no. Yeah, that's what I did. If I build that again, no. And then I tag it and then I push it. It should be very fast. See how quick that is? See how quick that, what the hell is it doing? It's quick. Oh, what? Okay, work this time. The gods, the demo gods have been kind. So now that's how easy it is to push a container. So as you can see here on Amazon, oh, I got two. Oh, actually there's kind of a bug on Amazon. If you reuse a tag, the old one gets the tag removed. It can only have one latest. So this is the old one. And once I get that, that's a problem with Docker. Everything, if you use a lot of images, you can have a lot of old stuff laying around. But I did actually email Amazon. I said like, if I upload two huge images and then share all the layers, do I get charged for one image, one terabyte image, or do I get charged for two terabyte images? And the Amazon guy says you get charged for the shared stuff. You won't get double charged. So it is, what do you think it is to be? Okay, so now we have a Docker image. Private, so this is your private code, your production instance. Now you need to get it onto your machines. And I'm trying to figure out how you do this without showing my key. This is going to be tricky. If you create a new key just choose here, I'll let it delete it. Yeah, but that's still, I won't be fast enough. You guys will hack me. Okay, I can probably get this running. Let me try and get this running in here without actually, let me just, let's just do it quick test. This might be a complete fail zone. Okay, so an Amazon parallel answer cluster is a collection of EC2 instances. That's what a cluster is. So in here you should have container instances. And each container instance is running a task. And actually what that means is a Docker image, I think. And a service is a collection of Docker images. It's really confusing. You're probably not going to get it. Just believe me, it works. I think the first thing I would do is, oh, I have to define a task. Okay, if this fails, I just, hmm. So task different. Okay, this is where you put the container name. Okay, okay, I'm just going to give this a try for two minutes before I give up and use something and use the command line. So this is the container image. Oh, that one. This is the most important thing. You name the, nope, what have I done? You name the image and give it a name foobar. Another really irritating thing about the Amazon EC2 world is that you have to define how much memory you're going to use in advance. I think I can get away with 128 megabytes. Let's do a soft limit. And the port mapping, as you remember, it's 2015. Then I have to go 80 or something. Well, this work, this could be embarrassing. I said soft limit. What does it want me to do now? Add, add. Okay, so container name, right, right, right, right. Is this going to work? Create cluster, create cluster. EC2 instance. How do you add one? Okay, this is where things get a bit. This is why, this is, I'm going to show you why you should not use the web interface because it's really confusing. Okay, I usually use the ECS images. Where are they? Why is it coming, elastic beanstalk? Okay, this looks right. Yeah, I'll just use this one. Let's just go for, me, me, me, me, me, me, me, me, me, me. Okay, I'm not going to use the web interface. As you can see, the web interface is very irritating. And it doesn't work very well. Okay, I'm just going to use the ECS. Yeah, let's see a line. Yep. Oh, damn. Thanks. Okay, so let me see. You put your credentials on a file, right? Huh? You kept the credentials on a file. It's not sharing. I'm just going to assume this is going to work. Okay. Oh, wait, okay. So ECS CLI, it gives you some, okay, I'm going to hope this is going to work. Okay, uh-oh. So I don't know how you guys feel about the CLI, but I find it a lot usually easier than using the web interface. And you kind of need to use the web. You need to use the ECS CLI when you want to scale quickly and things like that. So the ECS CLI is easy because it sets up your cluster and using cloud formation. So it sets up all the security groups and VPCs. You can actually set it up to use your own VPC if you have an existing one or your own security groups, but the defaults are very nice. So the whole idea about using, oh God, what have I done? The whole idea with using the ECS CLI is that, sorry, I can't. I just wanted to show you how it all works. Okay. So once the cluster is set up, all you do on the ECS CLI compose thing is you specify the image. So in our case, it will be that weird number, ECR, blah, blah, blah, slash PHP tutorial. You set up the ports and you set up the memory limit. And that is essentially how you do it. For more complicated services where you're linking different containers, then you have to have more lines and what have you. But this is honestly how I pretty much do production stuff and it works really, really well. So it works with the composer syntax? Yeah. What changes? Yeah, it works with the composer syntax. To be honest, I haven't really pushed it, I haven't. I keep things simple. As I mentioned, as I mentioned, I don't run more than one container on an EC2 instance because of the memory, because it doesn't share memory as far as I know. Maybe they fixed that problem, but since you can't share memory, it's really difficult to carve up the resources of a machine. So it takes a little bit of time to set up properly. And maybe I should just show you my crazy video. Nope, nope. God, I hate this, sorry. Actually, I actually use Wix and I'm still getting spammed by them. Four friends, obviously I would just write it myself. I just wanted to show you how this compose stuff works. See, this is what you do if you want to scale it out to two instances. But one, actually there's a lot going on actually. Once you scale out, you use the command to set up new instances, and then once you've done that, then you have to run another command to push the image out to the new instances. So it's not all magical in a bed of roses, but it does work. Okay, it's still creating, my God. Does anyone have like, want to do some dockery dockery things? Yeah, I'm just looking at, yeah, this whole thing just takes like half an hour, even if you're doing the right things. Unfortunately, it is slow to initially set up. There are some good things about the web interface. If you look at this events tab, that one there, it actually tells you if you're making a mess, it tells you like the errors. For some reason, that doesn't show you the errors on the command line very well. But events, if you're wondering why your image isn't being deployed or something like that, look at the events tab. That will save you a lot of time. Oh, I'm not sure what's rolled out in Singapore, but the ECS stuff is quite powerful. There's metric stuff. You can set up alarms. There's also auto scaling. I'm not sure it's available in Singapore. So you can set like an alarm to say that like, if you're getting a certain amount of traffic, you can scale to another machine automatically. It's quite nice actually. Oh, this thing is important here. One big problem with setting up this ECS is that setting up the load balancer is kind of like a bit hard for some reason. But the load balancer is really crucial to get right. Okay, it set up a cloud stuff. Okay, so what does that mean? So that means in your EC2 tab, no, no, no, no, this one, this means that it's got an instance running with the ECS agent. So it's got IP. Can you guys all see that? So basically this ECS is now ready for running Docker images. That's the theory. And you can use ECS CLI like PS, I think PS should show you the running images. Okay, maybe doesn't. Let me see ECS CLI compose service up. Okay, so to basically make the Docker agent start running your container, you have the Docker compose file there. And then you run ECS CLI's service up. I'm just running it with one of my testing. So then hopefully. So what is happening here is that if I actually, I could do this probably. If I set H into this machine, if I set H into this machine, I could probably show you, what's the IP? What the, I hate things I don't copy very well. Copy, what doesn't it? This is H, why doesn't it want to copy? Okay, anyway, if I managed to set for the institution, I would show you, you can actually see the agent doing a pull. So now if I do ECS CLI, it's actually running the container that I just pushed out there, I hope. No, what is it? Is it port 80? No, sorry, I could do this. I could do this, this is technology. Okay, this is my container. So, okay, let me just show you how quickly it is to scale. I think that should work. Sorry, I forgot the syntax. How do you scale again? Oh, something like that. So this is why I like the command line interface is that if you just click, if you just run scale size two, that means you're, and I guess this should, I should have timed it, shouldn't I? Let's just start timing it now. But I don't know how your workplace does it, but my workplace used to do an AMI snapshot and then start a new machine with, okay, that took about 20 seconds. I need to scale, okay. So I just want you to show you that scale thing gets another machine running, but then the next step is to do this. If there was a quicker way, I would let you know. It would be ideal if it did it in one step. Well, you can just like, I don't know, chain your shell commands together. But all in all, scaling a new EC2 instance, i.e. getting another one running, and deploying a container on it, I'm gonna say it takes about a minute. And previously, using AMI, I mean Amazon AMI stuff is actually kind of like containers before containers came along. But this takes in production about a minute. So let's say if I want to run MongoDB, it's not a container, so I've got to compose five, which means something. Yeah, you just name it, all the compose file in the agent takes care of it. So what I do in development is I like seeing the volume so that the MongoDB data is processed. Oh yeah, you would probably, you need a volume mount or something? Yeah, so it will mount up to EBS, is it? Yep, you could do it. That's probably a very good way. I don't know, does MongoDB play well with the EBS? Hopefully. Okay, I might have been lying about the minute thing, but trust me, it's faster than AMI. Who uses AMIs at work? Okay, AMIs take 10 minutes in my experience. This takes a minute. You can see here, it gives you updates, desired count, to running count. And with any luck, it will go to two. And I didn't set up the load balancer because that takes a bit of time, but having, in my experience at work, serving a lot of users, a load balancer in two easy two instances running the container, you can handle a crap ton of load, unless you write some PHP, that's insane, I guess. I don't know why it's so slow now. Am I doing it wrong? Okay, it's running now. As you can see, desired count, two. So that's how you do it. That's basically how you do it. And yeah, so basically two of these things are running a cut-down Docker-based system. And then if you go back here, it's all set up for you, hopefully. You can see, yeah, you can go into the service, you can see all the events, you can see how it's been, actually, you can make this faster because I think that the health check is a bit insane by default. Like it only after a minute of successful requests that it comes online or something like that. So there's little optimizations I think you can make. But in my experience, we can scale in about a minute. And yeah, I'm not too sure I can be billed with the load balancer. Can I show you the load balancer stuff? No, I'm not gonna do it. It's too complicated. Well, unless someone's really interested, I can show you how to set up the load balancer. I even have a script to help me set up the load balancer quickly. And you can do some, this stuff works for me, but you can set up like crazy rules about how many unhealthy hosts you can have and things like that. And yeah, when you have the load balancer running, you can do a zero downtime deployment, which is a pretty professional way of doing things. Unlike NEA who tell me that they're gonna be down for eight hours or something. I hate those people. Anyone work for NEA? How can your machine be down for eight hours? Insane. Yeah, sorry, guys, I wasn't very thorough, but the video is a bit thorough. There's too many little things to worry about. But this ECS CLI, you go PS, and it tells you the stuff that is running. I think that's how it works. Yeah, it's quite simple. It tells you what you're running. Oh, I mean, actually, let's try and do something funny. Let's try to, oh, back, back, back, back, back. Back, back, back. I think this is how you do it. Is that how you do it? So ECS. Look at the pose up. Oh, it's a service composer. Sorry, I forgot the command. You see, it notices there's a new task definition and then it coordinates the upgrade. It works, trust me, guys. It works, so I have to show you everything? Okay, how much time do we have? Still, oh, 20 minutes, thank God. But I read it wrong. Easy to get log aggregation working. What does that mean? Getting logs from all the containers. Actually, I haven't really figured that out yet. Yeah, that's why I mentioned it in my tricky part, the logging thing. Usually I rely on the app developers to have their own things that send shit back. But you can SSH if you enable it. You can SSH into your ECS and just do Docker. Like, I can show you how that works now. I should be able to just SSH into the bad boys. Okay, I need to set up a security group, probably. Let's go, how do you do this again? How do you change your security group? Down. Down? It's this one. The bot, the right, security, security groups. Oh, yeah. Oh, viewers. No, I want more ones. Yeah, and then you go add them. Oh, yes. Great. Yeah. Oh, inbound. Yeah, here we go. Add SSH. Try la, la, la, la. What? Oh, hmm. Oh, it's something weird, isn't it? Oh, EC2 user. Can you all see that kind of? Yeah, you can see what it's doing here. It's got an agent. And it should be running my new thing. If it's not, then maybe I made a mistake in the service. Was I unable to place a task because no container instance met its requirements? Insufficient memory. Oh, shit. Oh, well, at least it taught me what it was. Insufficient memory. Okay, well, anyway, you can figure out what the problem is. Sorry, that demo is not the most polished one. And yes, I do associate in there if something's going wrong. And I recommend you look at this events thing. And if you want a full demo that's not effed up, look at my YouTube thing. Okay, guys, that was really painful. Why would there be insufficient memory? Riddle me that. Why isn't there authorization? Commissions. What is this stuff? Allow everybody. Allow Henry. All actions. Add. Who invented this user interface? Principle is quite. Okay, who knows what's going on? Yeah, so the good thing about ECSCLI is, yeah, if you do make a mistake, which I just did somewhere, is that it will make sure your service is healthy. Okay, guys, any questions? I need to talk again. I'm gonna have another cry. All right, guys, what are the days of argumental projects? No, these are all of my channel. All right, while he's in the washroom, there is a tea break from four o'clock to 4.30. So the session at four o'clock will be moved to 4.30. And we will end about seven o'clock today. Sorry about that. But yeah, all right. And then, as that's all I'm going to say, we're going to wait for the time to come back and sit down and just sit back. Thank you. I really thought I was going to say this. Yeah, did you write all the lessons? No, not only for the women. Not the women, I would have never written. Women, that's what it's all about. I think it's a bit more serious. You've got more than you can imagine. Are you going to be in a DWS for a while? Check this out. Oh, so Alex. Alex is next, isn't he? Interesting. So I think he's using Elastic Beanstalk, which is like... It's like ECS-CLI, but for developers, because you don't want your developers to mess things up. So that's the way I... There's ELB for developers, so that they don't screw things up, but they're allowed to deploy and things like that. Well, I hope that was useful, guys. Really do. And if you have any questions, I'm happy to answer them, because sometimes I know what it's like after lunch. I just sleep. And asynchronous stuff is not that great, is it? I'm one of those guys that like to sit in bed, wearing hardly anything, launch YouTube, get a pen and paper out, make some notes, experiment, play with Docker. That's how I like it. Sometimes I do it at work, but usually someone's talking to me. Anyway, hope that was useful, guys. I'm going to run away. But does anyone have their own apps? I want to help you guys Dockerize an app. It's so easy. I noticed that I think they've got more food out there, by the way. I think they've got more food. Four o'clock? Here's a tip for you guys. Let's go hit it now. What a rush they may get there. Oh, out of curiosity, is anyone using PHP 7 in production? Good on you guys. I thought you might be crazy. Yeah, we used hack. Yeah, hack, yeah. Hack is better. Are you working for Facebook?