Placeholder Image

Subtitles section Play video

  • Hey, tech lead here and welcome back to another episode today we are going to talk about the newest and latest trend in sulfur engineering.

  • Developer operations Doctor, continue ization.

  • Today we're drinking tea.

  • It is actually one of my favorite concoctions.

  • So I thought I would do in this video.

  • Is first tell you what is stalker give you a little brief introduction about containers and all that explain about why it's used for why we're going to be using that today.

  • And then we're going to actually do some server maintenance and used Docker to save myself a little bit of money in my actual daily operations that I do on the websites and apps I run.

  • So first of all, what is stuck, er doctor is a trend.

  • It is a very hot trend in software engineering and not actually suffer engineering.

  • But I would say more in the developer operation side where you deal with systems engineering scalability actually in day to day operations.

  • Many suffer engineers aren't going to necessarily touch this site, but it changes the way that we write server software these days.

  • By the way, this video is sponsored by ALGO expert I'LL slash tech lead They're an excellent resource.

  • Check him out for video tips on coding interview practice covering day distracters algorithms and time space complexity.

  • Use code to tech lead for an additional discount.

  • Okay, doctor essentially takes your operating system, and this split into many self contained areas where applications can run it.

  • It's a lot like a virtual mission.

  • If you've heard of this term before, where people would take a single operating system and then divided into many small operating systems, each one thinking that they're running on their own system.

  • Well, the problem with traditional virtual machines has been that it's very heavy weight and it takes a lot of resources, and you don't really want to run too many on the single system.

  • It just overloads everything.

  • Doctor brings this abstraction up one more level.

  • Such that is not operating quite at that level and more on the application level.

  • All it really is is like a command line tool, and you just say docker run and then the name of the application that you want to run like PHP sent the West Debian bash my sequel.

  • You can choose the application and we just run in its own contained space.

  • So that's what doctor is.

  • It's a self contained space for applications to run.

  • Now, why can this be interesting?

  • Well, I think a lot of people, including myself, are still grasping at trying to understand what doctor is good for, where it can be used.

  • But I can tell you two key reasons that I figured out.

  • The first reason has to do with how it allows you to structure your APS and write code in a different way.

  • And then the second reason has to do with scalability.

  • So with structure in your APs with that lets you do is it contains your app in a certain space.

  • Now this is interesting, because when I would normally create a Web application, I would install a bunch of random programs onto the server.

  • After a while, I didn't really know what I had installed on there, and one thing I always thought was I have this website with a bunch of software and tools and the start programs on a certain machine and, for example, if I ever wanted to sell this website to somebody else, I always wondered, How would I do that, I'd have to sell the server and the lease on the server as well, and then they'd have to pick up the rental bills on the server.

  • The website.

  • The application was entirely tied to the machine to the server.

  • It was on what with Doctor.

  • I can't take this website and contain it in a container and image, and that is essentially the whole application and that can redeploy this image on any other server and duplicate the Web site functionality.

  • So that's one great.

  • Their brother is portability.

  • The way doctor is used is you have instructions indicating how to set up a server just the way you need it.

  • So I will always be able to know exactly how a server is set up.

  • As long as I'm creating the app, the doctor wait.

  • Like I might say, that website requires a certain technology stack like you need sent the West Region seven, my sequel version five, PHP, Version seven and Python and the Man Cash version, too.

  • And I could specify all that and that would say that the configuration files need to be done.

  • This certain Wait, This is what the configuration files are gonna look like, and all of that can be contained in the certain container.

  • So makes it clear exactly what are the configurations to get website to work.

  • If it works for me, it's going to work for you or anybody else.

  • And it gets rid of that world where I might have python version 2.7 and saw you have Python version three.

  • I copied the code over to your server and it doesn't work.

  • And then the last interesting thing that I think this soft structurally for your coding is it really promotes the usage of Micro Service's, which is a recent trend.

  • So Micro Service is, is the idea that you have many different service is that each do a single task.

  • As you can imagine, this would lend itself very well for scaling because you may have a chat server, and that is a single service you can imagine.

  • If your program were to get very big, you might want that contain on his own machine or even a group of clustered machines.

  • Then you may know one another server for cashing man cash or read this You mean another server to do know Js only another server running, maybe going for concurrent tasks or something like that.

  • Then you have another server managing your message board.

  • Now, in reality, most people aren't going to coat this way because it's just too expensive to be provisioning new servers for every little service you want to offer.

  • What happens is you just install everything on one single machine and then this one single machine is overloaded with a bunch of random technology like it's got note.

  • Go laying python PHP My sequel, man.

  • Cash reddest.

  • Everything is all contained on this one single machine and then all the dependencies get mixed up.

  • Maybe read this is using python version, too.

  • And then you install Go ling and this depending on Python version three and you've just got everything all mixed up together.

  • And pretty soon you don't really know what you've got on this system anymore.

  • You don't know if your website is running path on version 2.7 or version 2.3.

  • Everything is a mess and furthermore, you may find that sometimes you have certain service is where you can only run the single instance off like, for example, a PHP Web server usually does just a single version of PHP running.

  • It's not like you have version 5.6 of PHP running and then version seven of PHP running on the same machine, even though in reality you may have two different sections of code.

  • One is depending on the old version ones, depending on the new version with doctor and continue ization.

  • You can actually create separate spaces for each of these service is, and that allows you to release separate out your program and think in that way, too, unless you code in that manner.

  • And the great thing, which gets to the second reason this is so good is it scales very easily.

  • Doctor comes with a whole set of tools for deploying this across many clusters.

  • You can take your instances each service, each micro service that you have in each container and then allocate many machines to them.

  • Specify how many of the researchers of each machine you want specify rules about how they should scale, which would happen if they crash and it all scales up very nicely and makes everything scalable.

  • So that is what is so interesting about Dr Now what am I using doctor for today?

  • Well, let me tell you what's going on for me.

  • I run the Web server and it is about 10 years old and I'm using a fairly old version of PHP like PHP 5.6 or something.

  • And I needed a newer version of PHP to be able to interact with certain AP eyes for a payment provider.

  • You know, they wanted the newest technology, and in order to accept payments, I needed to use that.

  • And there was no way for me to use the newest version of PHP because I would have to upgrade my entire tax stack.

  • All the code would probably not compile crackly.

  • So I have now is I have to Web servers.

  • One Web server is my main Web server, and then I have a second very lightweight paper used Web server cause about 30 bucks a month for me, and it is running the latest version of PHP.

  • I use that for the newer service is that require the most recent in technology, and what I realized was I could just use stalker to run the latest version of PHP without necessarily messing up my other PHP stack.

  • So in this scenario, I'm not using talker to scale program.

  • I'm using it to contain a subset of the coat that I have.

  • So let's get into it.

  • The first step Piston stop Doctor, which is essentially a command line tool.

  • I'll be installing this for the scent of Wessel index distribution.

  • They have instructions for any other district.

  • You should go as well.

  • I'm installing to Community Edition and yes, I have been started.

  • And the first step we couldn't do that, they tell us, is we just run Docker run hello world and check that it is working and what this does is it would download the hello world container, which is the image that is pre created.

  • And it will just run that code and we can see that it does work in deep.

  • My second step, it's a log in to my current Web server and copy all of the code over that I would like to reproduce on this new server.

  • So I've locked in and I could do the copy.

  • Using either are single recipe.

  • I would just use SCP because this is a simple copy, so I've copied everything over now and now we will create our doctor container.

  • So I would do that by credit.

  • A doctor file.

  • There are many different images that we could start with.

  • I'm going to be starting with the PHP Apache version and I'm going to build this now.

  • So I run doctor bills, give the name like my app.

  • And I thought for the director that I would use its built.

  • And if I used docker images, I could see the images that I have here.

  • I've actually created a few other images here, but we can see my app is the one that I just built and I couldn't even run it.

  • And we can see that it is actually where the Iranians booted up PHP and Apache and we could try to access this.

  • Actually, in order to access it, you have to do some magic with the ports and expose the porch crackly to expose the ports.

  • We will pass in an argument indicating that safe Port 5000 war map to port 80 for the application for a D is a standard port used for Web sites.

  • When I run this and then the fire to try to access this website at Port 5000.

  • We're actually going to see that the website, shitload and yeah, actually, it is loading.

  • But what we need is to specify the files, the content for the web site so we can do that.

  • Using something called volumes were just pretty interesting.

  • In which you can map a directory in your current voter over for the container so that the container can access your files.

  • One interesting thing about containers actually is that they are generally supposed to be read only such that they're not modifying anything.

  • And the reason is such that this can be deployed across many different instances and that they're not really depending on the day that that they have.

  • So I was specified that the public HTML voters should map to Varda be tubby tubby slash html in the container rerun this And if I were to react since this website, I can see that the website is now loading.

  • This is pretty nice.

  • We're starting to pass in law parameters.

  • So I'm going to make a script called Dr Rhonda S H, which will encapsulate this command.

  • And so this script I first stop, doctor, if I need to I build it and then I run it by passing dash d to mean detached month.

  • If I run the script now, then I couldn't see that's running that.

  • And what if I want to log into the server?

  • Well, the way to do that is you run Dr P s, which shows the process is that you've got running.

  • So I find the contender that I won't get into anti logging with bash.

  • And here I could just take a look, see what's going on.

  • I can play around and tried to configure the environment when the interesting thing is, you don't have access to the max or any editors.

  • So it is kind of read only, and it forces you to kind of think about how are you going to edit the files using the set of Dr Rioux instructions.

  • You can go ahead and install me Max, if you want to do or vin.

  • But remember, what we're trying to do here is not edit the files directly.

  • We want to encapsulate the head.

  • It's in a set of rules in the doctor file.

  • That way this can be replicated across any number of machines after some messing around.

  • This was the final doctor file that I came up with, and I'll go over it line by line for you.

  • We could see we're doing the image from PHP.

  • Apache, I'm copying http configuration file for suddenly of Apache.

  • I'm gonna copy that over the default configuration.

  • Same thing for PHP.

  • I'm going to set up the PHP file exactly how I want it.

  • And there were a few terminal commands using the double arrow operator, which is for a pending and now upend these configurations to the initiation file for PHP here.

  • The last part here I have is exposes imports.

  • This really isn't needed, But it is self documentation, sort of to indicate which ports that this DR file is going to need this container.

  • And one interesting thing that I ran into here was I figured out that PHP doctor does not really support send the mail.

  • You can't release and mail out of it because the SMTP mail servers aren't really configured.

  • Right?

  • And what you need to do is actually use another surface.

  • What I'm using here is SMTP This of instructions here installs the container to install as a 70 peak and then copies over a configuration file for the password in authentication, the Configuration file.

  • I'm using an Amazon's SCS mail server to do the mailing and then the last parking figures Peach Petey use as a 70 people.

  • And so what we have now is we have an additional Web server running using the latest version of PHP.

  • And you know, this whole time I've been running this other paper used lightweight Web server.

  • It cost me 30 bucks a month, and I could essentially not be allocate the server because I've copied over to another Web server, which is actually running in the dock arised container.

  • And it's not missing up.