How to Deploy Azure Container Registry: Docker + Nginx + Container Instances

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hi guys today we're going to take a look at Azure container Registries in fact what we're going to do is we're going to create our own custom Docker container with our own Docker file we're going to use engine X to do that with Docker on a local computer we're then going to upload that into something called an Azure container registry and then we're going to take that image from an Azure container registry pull it back down again and actually send that to an Asher container instance and connect to it I hope you enjoy this demo so let's let's get straight into [Music] it so today we're going to go and check out these three Technologies we're going to check out Docker over here we're going to check out the Azure container Registries and we're going to actually deploy some engine X to that Asia container Registries so if you're unaware of what engine X actually is this is just a very basic web server it's about as basic as a web server could be to be honest and we're going to make a little HTML website uh for this thing to actually go and serve but what we're going to do is we're going to take this whole thing and package this up inside a nice little Docker container and apparently I can't spell this morning but that says container so let's start off with Docker we already had a look at this one in the past but we're going to go just move that out the way for the moment and what I'm going to do here is as an individual we have got on the internet this magical place called hub. do.com and over here on HUB dod.com there is actually going to be an image there is going to be an image of engine X okay this funky little web server what I'm going to do is I'm going to pull down that image to my local computer here and I'm going to run that as a little container on my machine I'm then actually going to go and connect that container over a high Lev Port of 8080 so let's just go and get that done first as the first piece of the puzzle that we're going to be working on here to push something to an Azure container registry and see exactly what that does so dropping over to my shell here I can type Docker and I should have Docker installed and we're just going to check that this is actually running at the moment so if I just do Docker PS ah the docker demon is not running on my machine let's go fix that let's just do services.msc wait for this to pop up have a look at where are you download Docker Desktop Service there we go let's just go and start that service just because on this computer I haven't actually got that starting from launch time so now that should be kicking in give it a few seconds okay so now our Docker service is started we do jocker stats you should be able to see there's no containers actually running on the system if you ever want to check that Docker is actually running properly just do this Docker run hello-world what that will do is it will grab a very quick container from the docker Hub location pull that down and actually run it all it does is output this hello from Docker so dropping over here to HUB dod.com I should be able to find the engine X image inside here that I want to manipulate there's lots and lots and lots of versions of engine X here but we just want this we just want this official build of engine X we want very very basic um options we don't even want to use any of these fancy tags and the different versions I just want the latest edition of engine X I can pull that down with this command here Docker pull engine X go and run that so if it can't find this on my system what it's going to do is Bounce out to that Hub do.com location and pull this down so that's now complete should be able to see Docker images and I have that engine X image nicely sitting on my computer ready for me to run this engine X documentation down here is going to tell me I can just do this Docker run command here there's a few different ways of Performing this what I want to do is I want just go and grab that external Port here so let's go and paste this in here move the move that off and just do engine X engine X so what this is going to do is going to do dock a run it's going to name my container sum engine X let's do this as not some engine X actually let's go and change that around let's change this to engine X test okay and this is going to run as a Damon it's going to run in the background it's going to run with the following ports this is the external Port the one that I will actually be accessing and this is the internal Port of the engine X application inside the container so let's go and run that thing and we're just going to allow that dock back end that should now be running so if I do Docker St I have a single container the engine X test container actually running it's taking a sum total of 12 megabytes worth of memory in here if I do Docker PS to see the current processes you can see that there's the docker command it was created 26 seconds ago so if I go to 127.0.0.1 and I do Port 880 on my machine we can see welcome to engine X the container is up and running that's perfectly fine this is not entirely what I want to do though I want to change this I want to have a different we a different um interface I say different interface a different site so let's go and exit this one let's go and delete that Docker container that's currently running in memory let's just do a bit of clean up here as well and get rid of some of these older ones too so to do this what I'm going to need to do is I'm going to need to build my own custom container now to do that I'm just going to drop over here into vs code and we're going to need some special files okay okay so over here on vs code to create create my own custom Docker container the first thing I'm going to need to do is create a Docker file all right so inside this Docker file what I'm going to need to do is going to need to type in some commands so what a Docker file does is it's basically a script for how to construct uh a custom container in this case uh the custom container I want to play with is engine X now I've already downloaded that image which is perfectly fine if I hadn't got the image downloaded it would automatically go and get that anyway so I'm going to use use from engine X let's make this a little bit bigger just so people can read it without I strin there we go and what we're going to do inside here is we're going to also use a copy command so we want to go and copy a HTML file from our local directory here and put that into the Container itself so the engine x file can actually or the engine X Program inside the container can go and read that file and therefore display as a web page now I'm going to need some some web page to do this let's just make an index.html quickly here um and in this index.html we're just going to do some Hut mol and we're just going to do uh some body and we're just going to say hello this is my container app and I'm going to save that so this is the thing that I want copied in so I want to copy this into the correct directory inside engine X so when I want to do is I want to copy the index or the/ index.html to this following directory which is user share engine xhtml okay so in theory what that should do is let's just go and draw this out um just so everybody's kind of aware of what's going on here I have this default engine X image and this engine X image itself has inside it the engine X service and it's also got a directory structure so that directory structure is going to have user share oops share engine xhtml over here I should retype this out rather than draw it but either way makes sense and what we're going to do is we've got our existing HTML image here and what the docker file is going to do Docker file is it's a series of instructions that basically says go and take this HTML file here pop it inside this container here so when my engine X service runs it's going to look for that existing HTML this is going to be a brand new specialized container it's going to be my engine X and engine X engine X container that has my custom HTML code in it this is a container that I'm then going to be able to redeploy multiple times if I want to so let's go and do that so dropping back over here I have my dock file from enginex uh copy that index.html to user oops forshare slinex HTML otherwise it's not going to work okay so I have my Docker file and I have the information inside it let's just go and run a build process here and we're going to run this command Docker build- T which is going to give a title to the image and- f is the file that's going to be C the docker file which is this one and it's currently in my current directory of dot so let's go and run that okay that's nicely completed and what I should have now is docket images and inside here you will see I have an image called my engine X created 46 seconds ago now what I can do is I can do the same Docker run command but instead of actually using engine x what I'm going to use is I'm going to use mik engine X down here that image and we're going to do this as mik engine X test and we're just going to leave this on that same port on port 8080 okay so now that's executed and running let's go and get that so you know what let's do this in a fancy way let's let do invoke web request and let's do the URI of 127 do whoops 127.0.0.1 colum port 8080 and we should be able to see there is my content hello this is my container app let's just do this on a web browser just to prove that point again 12701 1880 refresh that so it's not cached and we can see hello this is my container app okay so that's cool now I've got to a situation where what I essentially have is let's move this around a little bit let's get rid of that let's get rid of that let's get rid of that so what I essentially have is I have my own custom engine X container so I'm down here let's go a look so I'm down here this is me let's make this a bit chunkier okay um let's go and a little bit chunkier there we go and what I have is I have my container called mik engine X and it's got my own custom HTML it that's fine I've got this as a container I've deployed it onto my own computer and I run it on Port 880 but this is no use to anyone else what I really want to do is I want to get this up into the internet somewhere so what about if I've got something nice over here and buy something nice let's make this all a little bit nicer so you can see it a bit better let's go and stretch this out so what about if I have the azur okay and well I will have the azur why you're listening to this video so if I have Azure up here I have a few different ways that I might actually want to deploy this container um so somebody else can access it some of the ways of hosting it I mean for example there are um Azure container instances that we could actually deploy this to there are Azure container apps that we could deploy this to there is even Azure kubernetes Services AKs that we could deploy this to and a million other different ways that I could go in addition to deploying this as well if I want to deploy my own virtual machines if I want to do funky Arc stuff what whatever either way what I'm going to need to do is I'm going to need to get this to one of these guys over here now to do that what I really need to do is I need to have this piece of the puzzle in the middle this Azure container registry registry now you may be used to GitHub and GitHub is a great location because that allows us to take our code and publish it centrally to the internet and other people can come and download it and play with it a container registry is the same sort of thing for containers what I'm going to be able to do is I'm going to be able to take this container and I'm going to push this container up to an Azure container registry it's then going to nicely sit here waiting for deployment so this is going to be you know Mike's engine X sitting up nicely in this aure container registry and then what we're going to do is we're going to pull that into an Azure service like Azure container instances and we're going to have that nicely run inside Azure so before we do any of this um this thing doesn't exist so we need to actually go and create it so let's go and create it so to do this what I'm going to do is I'm just going to pop up a shell and this is going to run as administrator and I'm going to use the funky W gets here we're going to use WG install uh to our environment and we're going to use microsoft. aure CLI okay right whoops don't the parameter name e sorry WG it's not WG I'm not in Linux is it it's winget okay so there we go let's run winget let's going to download and install the Azure CLI for me uh and then I can use that to create an Azure container registry in a moment now sure I could create an Azure container registry uh through the guy if I wanted to but I'm still going to need to interact with this in a moment to go and push and pull some images so we might as well just do this stuff through the Azure CLI all right so now I have the Azure CLI actually installed on this machine Let's just a to check that that's cool now I need to do a login this will just hook my Azure um accounts up and I'm just going to sign in over here so I'm now logged into Azure I just popped up a nice little web page to say hey what account would you like to use here so now I should be able to run all my fun AZ commands uh like for example a resource resource list just to make sure this thing is actually working and there we go there's all of my stuff inside my environment it comes out as Json by default so let's just change that output to something like a table and you'll see I've got some stuff and some things great but what I want to do is I want to use this to go and construct my Azure container registry so let's go and make ourselves first of all an Azure Resource Group we're going to just call this not my Resource Group we're going to call this um ACR demo okay um we're going to change that from East us to UK South keep that in a nice civilized part of the world so so there we go I've got a nicely created Resource Group and now what I'm going to do is I'm going to just do this nice big chunky command here pasted in bit of a a ACR so a a container registry create now I want to create that in a resource Group we want to create this in that Resource Group of ACR demo uh the name of the container registry uh this does actually need to be unique so I'm hoping this will work mik ACR demo and the SKU is going to be basic let's just take off the duplicate in there because my mass managed to paste it in twice so there are different versions of the Azure ACR depending on what you're going to be using it for but this is just a very basic demo so we're going to stick with the cheapest option at the moment which is just the basic SKU there are many different services that we can do with this including plugging it into things like Defender uh to be able to go and scan your containers that are running inside your as container Registries this going to take a minute to install well to install to uh Loy uh I'm going to say a minute uh it's done so yeah that's nice um so now what we can do is we should be able to go and actually log into this so let's go and scroll through some of this information okay me user enabled false it's gone to the right subscription that's cool this is what I'm looking for the login server now notice I called my mic ACI demo it's actually G gone and thrown some DNS on the end of that Azure CR azure container registry. so I want that thing because what I want to do now is I want to do AZ ACR login now I'm logged into Azure but I also need to log into the Azure container registry as well so that has a different login type system inside here so I'm going to do the name is actually that's the name of my container registry it's automatically emitted that ACR IO and now what I should be able to do is actually send some containers to this all right so we need to go and take our existing image so if we look at docket images oops which is this one mic engine X and what we're going to do is going to go to tag that so it goes to the correct a a container registry so to do that I need to get this lovely little command we just need to do a docker tag and we're going to go and tag our mic engine X oops engine X and we're going to make this mik ACR demo dot what was the full one let's go and have a look at our thing here Mike ACR demo. aure cr. SL Mike engine X now that should link my existing image to the Azure container registry that we've just created so we should be able to do now dock a push uh mik ACR demo. aure cr. SL Mike X there we go so we've just taken that existing container that we created we tagged it therefore it's linked it to this container registry and now we're actually pushing it up to that container registry in the cloud and we're going to use that in a moment to go and take that and pull it into one of Microsoft's Azure services so that's all pushed up now if we go back to our container registry over here and we go into repositories we should see we've got Mike engine X sitting here ready for use so the tags of latest that's all good everything's up there there's a Docker pull command everything's ready to rock okay so what we want to do now is we want to do this part of the puzzle we want to go and get our little engine X thing we're going to go pull that we're going to shove that into an Azure container instance so we're going to run it in the cloud so let's go to AZ container instances here and let's go and create a basic container instance so we're going to give this Resource Group we're going to pop this into my ACR demo and we're going to call this container Mike's engine X server deploy this to UK South we're going to leave this on as a container registry the registry we're going to select is my mic ACR demo which is great um admin user must first be enabl for this registry in order to access the image during the container instance creation Okay so we've got a little bit of work to do down here so that little bit of work that we have to do here let going and learn more about the admin user in ACR and what does this say down here each container registry includes an admin user account which is disabled by default okay you can enable the admin user and manage its credentials nearra p blah blah blah blah blah blah blah blah the admin account is currently required for some scenarios to deploy an image from a container registered to certain Services okay so we basically got to turn this thing on before any of this stuff is going to work so how do we do that well we can do that through a CLI we can do that through Powershell but it looks like I can just drop in here into access keys and just enable admin user now because of the nature of azure and the fact that things update all the freaking time this appears to be an older screenshot this is kind of what it looks like now let's go to access Keys it's just a tick boox now rather than an enabled disabled so I've got a username got two passwords of this that we can actually regenerate as well so that that's turned on hopefully we should be able to come back here into our container instances let's go rebuild that process and let's go back to ACR demo let's call it Mike engine x uh server and deploy this to UK South and we'll deploy an Azure container registry select My kcr Demo there we go now it's rocking we've got no errors let's go and grab that mic engine X and we'll just use the latest image tag for it as for networking uh I can give this a DNS lab label name I'll use Mike enginex demo down here and we'll just use port 80 uh because that's the port that the server is running on so we'll leave the restart policy to be on failure we won't tag it and let's just go and build this container instance now what should be happening here is this nice little registry that's containing our custom engine X server that we built and that we injected our HTML file in into it's going to pull that thing into an Azure container instance once it pulls it into an Azure container instance what Microsoft is actually going to do over here inside Azure is this thing is going to have a public IP address welded to it and what we are going to do out here on the Internet is we are just going to attach that public IP address and hopefully hopefully be able to retrieve our custom website that we've built so let's just wait for this container image to actually deploy out uh there we go it's all done cool let's go to that resource and if we go and have a look it's currently running it's running on Linux it's got a public IP address everything appears to be good we even have an fqdn it's called mik engine X demo with 4uk south. aure container. so let's just have a look at that again it's Mike engine X4 UK south. aure container. so if I go and pop over to here of course you can do your own custom Registries if you want to Registries uh DNS if you want to but let's just go and connect to that now and hopefully fingers crossed this is my container app so let's just do a quick recap of what we managed to do what we managed to do was we used Docker over here to go and create a custom docket image which was our engine X server with our own custom HTML file nicely injected inside that we then took our engine X container threw it all the way up here to a container registry and stored it inside there so it was nice and happy and we then took that Custom Image and we pulled that all the way across into Azure container instances and we happily access that through the public IP address I could do animations but just draging stuff around the Whiteboard way easier so guys I hope you enjoy this little demo about azure container Registries and how to build your own custom Docker containers I know there quite a lot here if you've never seen it before but hopefully you can try and follow this demo along yourself it doesn't actually cost really much much of anything to do on Azure and you can tear it down immediately afterwards it's going to cost you a few cents at default or a few cents at Max so hope you joining me next time see you and you know the routine # like And subscribe and I hope you enjoyed this video and we'll join me next time goodbye
Info
Channel: Mike in the Cloud
Views: 593
Rating: undefined out of 5
Keywords:
Id: cvKwvGNrRJo
Channel Id: undefined
Length: 26min 24sec (1584 seconds)
Published: Mon May 20 2024
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.