 or a pillow or something. I mean, lunch was really good. So, just to finish the interesting fact about translating the Ninja Turtles game back. Just to finish that, the way how I tried to translate was actually just switch the keyboard from English to Serbian. So, like, if you have a W that was a NYE, or a thing like that. Yeah, it never worked. So, okay. Talking about the Docker. Blue Whale, I had to put this claimer at one point when I tested this dock in the office because one of the guys asked me, like, are you aware there was like a weird game that was popular in social networks last year called Blue Whale? So, not only geeky stuff, no, nothing other than that. How many of you is familiar with Docker? How many of you work daily with Docker? Okay, that's not so bad. How many of you thought Docker was the same thing as Vagrant when it started working with it? I mean, I did so. Okay. First big difference. Difference between Vagrant or any kinds of virtualization compared to content and visualization. That's like really important. So, let's say on the left side here, you can see basically how virtualization will work when you want to run, let's say you have three exactly same applications that you want to run in Docker environment and you want to run them in VM environment. In VM, of course, you have your infrastructure that's basically the same in both cases, hosting operator system. Again, you will need to have some system that will run. And then we come to the first difference. We have a hypervisor when it comes to virtualization and we have Docker engine that will do the rest in this case. As you can notice, we have like huge boxes and I intentionally put them in this big guest OS. It takes memory, it takes storage and there are few more important things that you can't really optimize properly when using VM compared to Docker or any container-based system at all. Another big thing and this is actually how we are doing it in our company that is we are running VMs on KVM and on every KVM we have bunch of Docker containers, different Docker containers. Currently, we are running like 12 or 15 different microservices and the goal is to reach to a fully scalable system that you can configure in real time selecting all the images you want to be provisioned on your machine. So instead of installing a package or something you can just pick what microservice you want to run because Docker actually allows us to make things work like that. We only configure Docker, we build applications like they are all connected. Of course we will have some kind of dependencies if you install application C you need to have application A or something like that. But in general, we did it in a slightly different way than it was usually before. One big thing, actually one big difference when we talk about VM or Docker or for me Docker or VM is how it manages resources. If you wanted to run a virtual machine I'll give an example here with one gig of RAM and one core. You will use 10 gigs of RAM and 10 cores with VMs. While on the Docker side you can say I want to allow this machine to go up to one gig of RAM and one core. It won't go over. That means in a bunch of scenarios where you don't actually utilize most of your memory and most of your CPU your machine will somewhere be idling during that time. While with VM you can't use the rest of the resources that are not there. They are there just locked in or you can try to do it but I honestly don't suggest to try something like that because most likely you will run your whole VM host down because it will run out of memory or something like that. Next thing that's really important is how to deal with the data that you have on your Docker machine. Let's take a scenario where you want to run WordPress but you want to have access from those files on your local machine so not that you have to go into your VM then from VM there is not really SSH for Docker but you can access the shell of every container and then see the listing of files. You can move that all the way up to a mounted or shared folder that will be visible to your host operating system similar like VM does it when you configure your SharePoints but also it can keep files locally. For example if you are doing any kind of caching or session files or whatever is related to that particular container it stays inside. You don't have to publish it outside for other machines or other people to see it. It brings on a security level but we will touch that a little bit later. Also there is a really good thing about networking when it comes to Docker. With VM you will have to create your own network to design your own network to assign IP addresses or if you use NAT then you will have different kind of problems. Here you can name your machines. Let's say you have machine A, machine B, machine C. Both machines have NGINX installed and they are exposing port 80 publicly for that container host. You can just use HTTP machine A or HTTP machine B from inside and access those machines because the whole networking layer on Docker is something that was actually designed for that to help you not waste time working on your network configurations more time than you will actually spend working on your application that you want to run or applications. Like anything else we hear also have the CLI commands. Yeah, it all starts with Docker. A bunch of them really. This is just an example and we will see this a little bit later how you can set up a simple WordPress installation in Docker on your local machine and run it in... well, basically in milliseconds if we don't take the time needed for download those images. Also like let's say a big one Docker supports configuration files where you can set your commands that you want to run to set up every environment in exactly the same way. Basically automation that's already built in and it will allow you to run containers in such fashion that let's say you want to do auto scaling. Every container will be like the other one. No differences, no nothing. You set the version of your operating system here it says from Alpine 3.7 who is new to Docker, Alpine is Linux distro that's like five megs originally if you don't install anything on it. So it's really fast. It supports basic stuff you can install Nginx, PHP, MySQL and most of the software that we basically need in our daily operations we can run on it. With everything set you will get to let's say 160, 170 megabytes of storage used compared to let's say CentOS that I personally use or Ubuntu that will go over 400, 500 megabytes originally without the packages you will need. This also means you will have to install some basic stuff there that are not supported by default but that means your machine will be exactly configured like you want for the particular application for a particular version of software that you are using. The next big thing about Docker is Docker Compose. It basically creates a small network of connected containers that support different applications running inside them and they are all running as one like I said we are building a system that will have hundreds of this so basically this is how we will do it we will just make a Docker Compose file differently for different clients and we will have exactly what we want. We will have different applications set up for different clients and all coming from same let's say big code base. Docker Compose is there to even automate more already automated process where in this particular case let's say I want to install a database and a WordPress we will see this in a little bit later but I want to install WordPress of course on any database you simply define the name of the image you want to use. Images are coming from Docker Hub you have a website on urlhub.docker.com where you can find a bunch of already built images. Image is really something like we have on Vagrant or any other system for visualizing your software where it's simply a list of commands that will be done to again have one machine always act in exactly the same way. It's great for developing teams unless you have a lot of people working on Windows but I will talk about it a little bit later. And here also you can notice on the right column right near the footer it says volumes. When I mentioned the volumes that are supported here it will create a volume that will be persistent for this compose. It will not be deleted when you kill the machine when you restart the machine it's always there while if you destroy a container without volumes if you use local files only all the files you used previously will be gone. If you use shared or mounted those data will even remain there until you actually delete them from your machine. So when you can list volumes in the same way like you can use the list containers or as you can list images that are currently installed on your host in the same way you can use volumes. So if you explicitly delete the volume only then the data will be gone or of course if you kill the whole host. I already mentioned a few things when it comes to Docker in WordPress development. I also mentioned don't try to write on Windows. I mean try it but there is a great possibility you will have lots of lots of problems and issues that you will just eventually have to say I give up because either you will start to work directly with Docker and Windows trying to solve those problems I don't think there is another way. I had two developers trying to set up their development environment on Windows. First problem comes when you try to check out some files that can be solved in Git but still when you check out files it will change how the line ends and it will pretty much break the whole thing when you try to run such file in Linux environment. So the thing is you have everything under version control including your Docker files but when you check them out with Windows the Git on Windows will automatically change the line ends when it comes to new line ends. That file will be served not to Windows but to Linux because you are running your virtualization software and that file that Docker file will be given to not Windows but Linux machine. You can try fixing it but then you will get into some other issues and it's totally waste of time. That's one problem. That can be solved if you optimize the Git a little bit. Next big problem is actually sharing the amount to the media between your host machine your vagrant machine and Docker container. On Mac on Unix like systems that pretty much works out of the box. So I run the VM on my machine in that VM I run the Docker container whenever I change something in that change will be replicated all the way to the container with Windows that doesn't work. It usually breaks somewhere between communication on VM with container. No particular reason why no error log no nothing. Just the change is not propagated all the way down to your container. The way around it is to basically destroy that container and rebuild it again. It's not so time confusing as it's just like a bug that's always behind your on top of your head and like why this doesn't work. So I strongly suggest and I even said that so go with Google. If your developers are really really really hooked to Windows unfortunately you will have to make them use Linux and if they want to use Windows on their machine when they're not working on that particular project by all means they can but they have to do a boot on that machine where they will run the code from Linux they will eliminate the need to use the VM and everything in this way. This is something that I try to play with a little not really microservices but I try to split WordPress into its let's say core sections which is the application server database and content. I use the shared storage for application and I use the different container to run the database different databases because this setup was meant to actually support multiple installations of WordPress so persistent storage is a local mounted one where I can change it so my teams my plugins are stored per installation but VP includes or VP admin is always centralized. One problem that I noticed but it's not really so big because WordPress does that automatically is when there is an update. That means that first site that catches the update of your WordPress core will update the core for the whole network. This will just require to run the database update because the database is not shared. It's actually something that let's say kind of works I'm still not so certain I will put this into production. There are still like glitches that can happen from time to time. And a really good thing about this is the engine X that's basically a load balancer can also be a container or two containers behind it I can have multiple application servers that will allow me to handle the load very good and in very fast way. Originally I mentioned the speed so usually when you take let's say Ubuntu and you run big enough what do you think how long it takes from the moment you hit enter until the moment you can run bigger SSH sorry? wait a minute without download so let's say you have the image gashed how much time is needed 15, 20 depending on your host machine speed and how much resources you dedicated. When you hit enter on docker run to create a new container that's been done in a matter of milliseconds. So speed is something that really helps in this in this case. Yeah this was the last slide so do you have like in theory level just some questions we will move on to something that I haven't tried before which is live coding we will try to get from the moment you to run the vagrant to install vagrant to run docker run it set up the nodes and everything and we will try next let's say 20 minutes to have the functional WordPress website running on docker so can you give me some more questions again but I think that I was just thinking about this reason again figuring out is it the running on docker machine on market is it the running on docker machine on market yes but the OS 6 for some reason doesn't have that problem it runs pretty smoothly most of the times again there are issues and Linux is the only native Windows and OS 6 will be supported as different kind of hosts where basically the kernel of your system will remain the same and only the packages will be installed for your for the containers you want in this particular case we are basically putting the VM in there so we always have the same kernel on top where we put our containers for application if you want to run Windows applications inside docker that works if you want to run it will work I know that docker is really working on heavy development where they will allow you basically to run Windows applications in containers same way as we mostly run nginx or mysql so let's try this originally I'm working in a software folder where I already have a vagrant just in case so the vagrant machine is already set because it will like someone said take like 20 minutes to finish everything and that's a little bit way too long so you can start counting time for things like this because you will see that even the shutdown of a VM will take a while I did a benchmark on this machine before preparing this talk and it was like 22 seconds I think to bring machine back from halt state this particular machine we will see it's like type of commands that it's pretty much instantly when you hit enter on docker run I guess as I mentioned it goes instantly it will show you the hash of the container that was created and really seconds later you can check the listing of your running containers and if everything went okay you can see your container already running okay so we have so the one the version I was using here just if someone wants for the nodes or something the command I used to run as vagrant and at minimum of Ubuntu trustee of course 64 dot so this is the one this is the vagrant setup I was using here and one thing I did instantly was to change the vagrant file when it comes to networking so config VM network, private network and I dedicated NIP to 191.68 which is today basically also I have put the same thing in my host file so I have workamp.sofia as the main depth oscillator how it works also what I suggest especially when you're trying to test things never let your vagrant machine take as much resources because it will kill your host machine sooner or later but one time you will definitely do that so one of the things I always do is I change the virtual box memory to take maximum of two gigs for what I have been working on it's more than enough if you really don't want to run some memory expensive processes where of course you can dedicate more and since the WordPress itself is not so CPU hungry system I don't limit the CPU but in certain situations I will put a limit there also and I would say that it can take max of two cores so even if there is a problem, if there is a memory leak in my script it will never actually kill my machine but I can kill that either that container or either that whole virtual machine and start from the beginning ok so if someone wants to put the stock watch on vagrant opt is running right now and it will take a while before we see the output and before we were able to log in is this font size good? to make it larger? so we are ready to go on which is and we are in you can see that the IP address is as I defined it and I really always do that it's a matter of choice I don't like port forwarding or something like that I like to have like a dedicated IP for machine hardware development ok so next thing is first how actually just a docker list of all commands that docker supports really a lot of them and I will only use few of this today but it's like something you can read and see yourself what what there is that you can do one thing who's really interested and not previously worked with docker I suggest that you check docker swarm which is a docker solution that it will allow you to run docker containers across different machines it's that's inevitable that you will not always be capable of vertically scaling your machine there will be a cap at one point so you will have to start horizontally scaling your hardware setup so docker swarm will actually allow you to do that so let's see docker containers are we running right now first command docker ps will give you only the running ones the docker ps-a which is actually short from ps will give you the list of all possible containers currently defined on your system so since I want to go from the beginning to show you how long it takes to create the actual container not just restart it I will delete both of this so for docker rm or remove I can use either container ID which is here in the left column or a name which is all the way in the right column docker remove my SQL as a result you will receive the name of the container that was or containers that we deleted and let's say now I want to run and if we go here of course vc.sof is redirected to the domain we had two IP address we mentioned before so there is nothing nothing here let's say docker run we will give a name to this let's say it's nginx and we will set a volume between the host machine and the docker container let's say this from the from the host machine will actually be user share nginx share nginx html this is the default path where the nginx root will be set we won't run it as a domain and the last part is which image to use that's it that's how long it takes to create a container compared to those 15-20 seconds we had before this was really instantly and as you can see it only took a couple of seconds to type it but it's already up and running for 5 seconds and now let's see here and nothing will be there the reason for this is remember this part port 80 so this container will use port 80 but your host doesn't know or you didn't tell your host what to do with it so again we will remove this okay it's running so people just asked to force it and instead of just doing this before we started to dynamic we will say okay but forward port 80 on the host again matter of seconds it's running and now this is the big difference any id on port 80 will be redirected to port 80 on this container if we go back how long we can stop it the way how and also now if I want to change this file I will go on my local machine to this path and I will change the index html file that's the power of volumes in Docker this is something that will actually or possibly not really work in Windows so this change will require you to change the whole to recreate again the container so it can be created with the different code base originally there so when we got to this this is just the engine X so we can go from here and start to build our own machine but that maybe doesn't make sense so this is the official repository on Docker Hub for engine X we have the same thing for MySQL so let's set that one up and we will get to the point where we will make a connection between our third container and MySQL container so again we have same thing as before we want to create MySQL we want that volume to go to this is again default path so if you do not use any kind of customizations during setup you can just use the default paths and expect they will be there again we need to set the port and Docker also supports environment variables which in this case will be variable for MySQL with the password and let's go in the background and use MySQL but if you check here supported tags and Docker file X if we go with just MySQL it will automatically set up fast with MySQL 8 we don't want that so we will use the latest 5 version of MySQL where we can use just 10, 5, we don't have to put 5.7 or something like that and this is the reason why I'm putting 5 here and again since I already had these images downloaded on my machine prior to this talk everything is instant with it even if the image is not there it will just take couple of let's say seconds to download but just in case I want to be certain if the Wi-Fi goes off that I have all those running locally now if I again check what's been running there it is 28 seconds ago and running for 27 and again it's forwarding the port 2306 to 2306 on the container we are certain that everything we do with the database will actually be there another way how we can test that is I have already set a connection but I can just read again we are connecting over the SSH so we need to open the SSH tunnel to our machine to connect to it using the invagrant of course MySQL is so, so, so hard again, host root we set the password here so we can use that password and we can simply connect to our machine of course there are no databases but if we try to add WordPress it should actually work yeah it's there so we can set any table just to make sure so we set up the engine X we set up the MySQL but in order to avoid setting the PHP and writing all the commands that we need to set up the Dockerfile for our WordPress we will simply go again on Dockerhub and for WordPress which will give us all the tabs and configurations that are supported for this particular case so yeah we will just go with the latest no need to do anything else and we will simply do that again running so name WordPress link this is new thing that we haven't used before remember when I said that Docker supports networking if you are using Docker compose well since we are not using Docker compose here we need to tell Docker where to create a link between our containers so in this case we will say create link to our MySQL uh to contain the name MySQL running MySQL again here let's put in the name where here we have WordPress sorry I don't know all the exact options that's why I'm checking the official repository okay this is what happens when it can't find the installation locally it will try to download it it will only since our internet is not so bad this will be really fast and yeah as soon as it is done it's saying that it's up and running again let's check what containers we have not and there it is but now we have a problem we can't connect our WordPress to port 80 because we already have another NGINX running so this is one limitation you can't use of course same port multiple times you need to be careful with that if there are some problems always check ps or always check even this can be a problem always use all and see everything that's going that's that's been running out there so let's again remove NGINX we do not really need it again it's running let's force it we definitely don't want to have it there and now we are here but now we have to also delete the WordPress again and recreate it because we didn't do the port forwarding originally if you want we will see donker press is pointing where it should and hopefully we will see this it basically takes just a few few minutes to get and only two commands to get your first WordPress installation running in Docker if we still have time I can show you also if you are interested how to use Docker compose where we can narrow this down to only one command and one configuration file if you are interested into that or you just want to go and have a coffee okay who wants to go have a coffee they can have a coffee I will make a short break to get this removed and get going with config file as you can tell I'm usually using the Docker compose that's why I'm having so much issues running all this okay and now I will just switch completely to root here it might be easier because I want to do something but if you are working daily with ptp composer I have a lot of problems always adding that R to the end which kind of gets annoying when you figure out you just spent 15-20 minutes trying to debug what's wrong and then you figure out you just have one R expert so in this particular case we need to define the version this is because Docker is out there for I think 3 or 4 years now but it's already Docker compose is already in version 3 because they are really working on heavy development and making new features and making it better day by day so here we need to define sorry and now we define services that we need to run our Docker compose WordPress first we need our database and our database will come from image as we saw before mySQL then we want to use the volume which will be mySQL goes again to this place restart always so in case the node gets the container gets destroyed or goes down it will automatically go back with this command Docker keeps track about that this is that E argument that we used and we will say mySQL