Using Containers without Docker Desktop

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
you want to develop a solution that uses container technology but you can't use Docker desktop because of the license or maybe you just want to use an alternative let's go and set up our development machine so that we can use containers [Music] [Applause] good morning good afternoon or good evening whenever it is that I find you and welcome along to the channel so today we are going to be looking at containers of all kinds of containers so we're going to start with looking at Windows containers so I've got a fresh install of a Windows 11 machine so let's go and see how we can enable using Windows containers on this machine so the first thing that we need to do to enable Windows containers is going to enable hyper-v so let's go to the features aspect of windows and we can see here we've got the hyper-v option and when I drop that down you can see that hyper-v platform is actually grayed out and the hyper-v hypervisor is grayed out and the reason for that is because I'm running this machine as a virtual machine so you won't get this if you're running this as a host machine but what we can do is if you go to this URL and we look here it talks all about enabling virtualization and what you need to run in a Powershell prompt is this particular command here to enable virtualization inside your VM and you give it the name of the VM there so I am going to go and do that right now and then we'll be back and we'll carry on okay so that's done and we are back inside of our virtual machine again so let's go and check our Windows features again and hyper-v is now all enabled we can select it and we get all the hyper-v so we need to turn all of these on so let's do that and that's going to ask us to reboot again no doubt so let's go and restart and then we'll be back again okay so that's rebooted so now let's go and download Docker so we can go to this URL win static stable x8664 and we can download the latest one you just have to pick the one with the latest date so 2010 22. so let's download that one and let's open that up and just extract it to our C drive so we've now got a C Docker folder and inside there is our Docker executable and our Docker Daemon so now that we've got our Docker demon we can open up a command prompt as an administrator and first we need to go and pass it through so let's go and set some path options so on this PC we go to properties Advanced system settings and environment variables and we just append on to the path a new value for C colon Docker to pass it through that Docker folder then we can okay out of all of this and let's just reopen that command prompt so it picks all of that up let's blow this up a little bit so now if I go Docker d it starts up and I'm going to allow access through the firewall to that and it says it's listening on this pipe so if I open up another command prompt I can do a Docker PS just to list all the containers of which there aren't any but it will show it's connecting to the docker demon correctly so that's a good start so now let's go and set this up properly so that we don't have to run all these command prompts left right and Center so the first thing that we need to do is over in the program data folder which we can get to by doing percent program data there is a Docker folder now so we can go into that and we can go into the config folder in there and we can create a new text document called demon.json or damon.json depending on your preference so let's open that and it's a Json file so we need now boilerplate brackets and then inside here we can add a host's value and that is an array of hosts that the demon is going to listen on and we are going to set it to listen on all of our IP addresses on Port 2376 by default Docker uses two three seven five so we're gonna bump that up by one just so that we can prove that we are actually running on that particular Port so then we can register the docker demon as a service using Docker D register service and then we can do a net start docker and our service is running you can also if it's your preference you can run up the services.msc which brings up the services dialog and inside here you'll see there is a Docker engine which is now running because I'm running so you that's how you can manage it as well if you are more GUI oriented rather than command line oriented but netstart does exactly the same it starts that up so then we can start a new command prompt this time one that's not using the administrator and we can do a Docker we can tell it the host is TCP 127.0.0.1 2376 and do a Docker PS and we see that that is talking to our Docker demon on Port 2376 as we would expect but we don't want to have to specify this minus H every time so let's come back over to our system properties and advanced system settings and environment variables and this time in the variables for my user I'm going to add a knot there a Docker host variable and I'm going to put that tcp127.0.0.1 2376 in there so now every time we run the docker command it will look at that Docker host variable and pick that up so if I exit out of this one and then bring up a new command prompt now if I just do Docker PS in here we can see that we're now getting exactly the behavior we want our Docker demon is running as a service so I can get rid of this other command prompt and I can just open a command prompt now and do Docker PS and it talks to my Docker demon so let's just try a and run a container so let's use the default hello world and we see that I get an error from that so we've forgotten to turn on some more features inside windows so we need to turn on containers in here foreign -booted after enabling containers and we're back in our Command Prompt again or Powershell so let's try our docker run hello world again and we get our hello from Docker so that's our Docker container up and running on Windows containers and if I do a Docker image list we can see there's my Hello World Docker image that I've downloaded okay so that's given us our Windows containers so now we need to turn our attention to how we're going to handle containers that we want to run the Linux operating system on which is usually the more common scenario so containerization is more of a Linux thing than it's a Windows thing so most of the platforms usually support Linux first so you want to really be running your containers using the Linux operating system not the windows one so how can we do that on a Windows desktop so the first thing we need to do is install Windows subsystem for Linux so we can do that using a terminal in administrator mode and we can just do WSL install we'll let that whiz through and it's probably going to ask me for a reboot after that so we'll come back after it's done all of that now we're back after our reboot and it's fired up this terminal on reboot saying that it's installing Ubuntu so we'll let that do that and that's it we're there we've got our new Ubuntu 2204 version up and running and we're logged into it inside of windows so that's a good start so the next thing we need to do is turn on system D so the way that we can do that is to do a sudo Nano and I'm no Linux expert by any stretch of the imagination so we give my Linux skills but we need to come into here and we need to add to that WSL config file a boot section and a system D equals true nothing more than that and then we can output that and exit out of that that's control o to do that and control X on Windows and we can verify that that's installed using system control list unit files dash dash type equals service and if that gives us back a load of services which it has done then that shows that systemd is installed let's carry on the next thing we need to do is make sure that our Ubuntu is completely up to date so let's do a sudo apt-get update and then we're going to bring in some packages so we're going to do a pseudo at get install and we are going to automatically accept those and we want apt transport https we want CA certificates we want curl we want gnu PG and LSB release and I've spelled transport wrong let's go and fix that get all of those and then this next command I'm going to paste in because it's just too long but we need to curl and ROM Docker bring down some packages so let's go and run this one and before I go any further I hope to give credit to where I got all this information from so I got it from Marcus Lippert and he goes through the whole idea here of installing on Windows using the subsystem for Linux so that's where you can copy and paste all of these commands from if you need to so where did we get to so the next one we need to run is this one so let's just go and do that and then we need another sudo at get update and then some more package installs so Docker CE Docker c e CLI so let's go and get those okay so I'm going to reboot Linux at this point so I'm going to exit out of my Linux installation come over to my other Powershell and do a WSL shutdown which should kill Linux and then I should be able to re open a Linux terminal again and it will restart it this time with systemd enabled and then if I do a sudo system control status I can see that jobs are running and the system control is actually starting services and interestingly I can see the container D services started there so now with all of that up and running I should be able to do a a sudo Docker run hello world pulling that image hello from Docker and we've now got our hello world Docker container so likewise I can do a pseudo docker image list and I can see the hello world is downloaded and pseudo Docker PS to see that there's no containers running so that's Docker running inside WSL but can we get these two things working side by side so that it's easier for us to manage and work with both of these things and we can do that we can do that by setting up a Docker context for the Linux side of things so what we can do is copy the config of the docker service and then we change our Docker service to use localhost 2375 instead of the pipe that it normally uses so we can reload that config and then restart the service and now Docker should be listening on Port 2375 which we can prove by porting Docker to use that particular host so now we need to set up the host so that it defaults to this so we don't have to keep typing this in every time so similar to what we did inside of windows so we can do that by editing our bash profile and we can do the same thing we can set up an environment variable inside of our bash profile to just set up Docker host and we can write that out so now our Docker service inside Linux is on 2375 so we can come over to Windows and inside windows we can do Docker context to create and we give it a name of Lynn for Linux and we give it the host that it should use to reach that particular Docker context so our Port 2375 and so now with that I can specify the context on Windows of Linux and do a Docker PS and it shows me what's running inside the docker demon inside of Windows subsystem for Linux so that's good we've got our Windows side talking to our Linux side for our containers so we can easily communicate for those but what we've lost with Docker desktop is any kind of graphical user interface for dealing with our containers so if we're not comfortable with the command line what can we do to help us in that regard so there is a an application out there and there there are several actually that deal with sitting on top of the docker demon and help you in terms of an alternative UI in dealing with management for containers and stuff like that one of them is this portana so it gives you a nice UI representation of all of your images and what's running and helps you manage those and tidy all of those up so it just makes life a little bit easier than always using the command line so let's go and have a look at how we can set this up so inside of our Linux container we need to do a Docker volume create and we call it portena data and then we need to actually pull down a container and run it so it's quite a lengthy command so I'm going to paste it in so and I'm going to need sudo on the front of that so we're going to run the container portana data the latest so the Community Edition or portainer and we're going to expose out a couple of ports so Port 8000 and Port 9443 is the default that these use for the secure ports and insecure ports so let's run this and we can see that our portana container is running so now if I go to a browser and go to https localhost 9443 we're straight in and we can start setting ourselves up let's just go and do that so that we can see that this is working so we create ourselves an admin user let's just go to go started and let's see what we can see so if we go into this local environment which is our local Linux Docker Daemon we can see we've got two images which is what we would expect what we've done so we've got the hello world latest let's blow this up a little bit and we've got our portana instance as well or image so we can start seeing a more user-friendly approach and we can see all the times that we've run hello world that it's exited so now we can do kind of useful things like tidying up the exited images we can just go and get rid of those to tidies up our local environment and we don't have to worry quite so much about the command line but it gives us a nice visual representation of what's going on with our container environment and that's pretty much all I wanted to cover in this video so we're now up and running we can build Windows containers we can build Linux containers we can easily manage them all without Docker desktop so we can do this in a commercial environment where we're being constrained by the docker desktop license so I hope you found this useful and if you did then please don't forget to hit the like And subscribe buttons as that helps this video reach more people and helps more people out so with that I want to thank my sponsors of the channel without whom the channel wouldn't be growing so thank you very much for your contributions it's very much appreciated the links are in the comments below and thanks for watching and I will see you in the next video
Info
Channel: The Pragmatic Programmer
Views: 6,613
Rating: undefined out of 5
Keywords: hyper-v, windows 11, wsl, docker, docker desktop
Id: i7i4vZBOpWM
Channel Id: undefined
Length: 20min 8sec (1208 seconds)
Published: Fri Jan 06 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.