Docker Containers On Proxmox! (Two Different Ways - No VMs!)

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hey there this is aston martin ak the thinker dad first of all let me wish you a happy new year because well this is uh this channel's first tutorial video in this new year in this video i will show you how i run docker containers on proxmox so if you're interested keep on watching but first if you're new visitor to the channel welcome on this channel we deal with home automation home networking and sometimes with related stuff like the iowa electronics and even a little bit of 3d printing anyway let's continue with today's topic let's start with the funnest thing so when a newcomer first uses proxmox probably he or she will be interested in what can you run on proxmox and yeah galaxy containers and vms are obvious but the question arises can you run docker containers so as those are not present on the ui uh he or she will just start googling and eventually we'll end up at this document and then it's uh this is the faq document of proxmox and it's not a long one and the last point details what can you run so you can run rxc lxd containers proxmox containers docker containers or can you so it clearly says it is not recommended to run docker directly on proxmox v host also it says if you want to run docker containers you can just use a vm and run those containers inside that is pretty easy pretty obvious but probably not the most resource efficient solution so if you think about it proxmox is just a glorified linux distribution it clearly says here it is based on debian and debian is pretty much able to run docker so technically you can run docker containers on proxmox itself but before doing so let's dig deeper into this so there are pros and and cones here that you should consider before uh jumping into things so when we are talking about running something on proxmox it can mean a couple of different things so it can be an alexi container it can be a vm or something running inside the vm or actually it can be something that is running on the operating system that is under proxmox debian linux in this case so in this situation we are not really running stuff on proxmox as in it is pretty much running besides proxmox on the operating system but it's still doable and proxmox in fact can help you with doing that but you must note that if you run something besides proxmox it will be pretty much invisible to proxmox itself i mean you have the resource monitor and you will see that something is eating up your ram or eating up your cpu time but uh these are these info some are coming from the underlying operating system and proxmox will not be able to tell you that this is this or that container or whatever you run so technically you can even run your own services on top of debian besides proxmox but proxmox will have absolutely zero control over those and this applies to docker containers as well because docker daemon is a service running on the operating system this also brings one consequence with it so when you are using proxmox in a cluster you are able to migrate different vms between different nodes of the cluster if you are running something on the host operating system outside of proxmox you obviously lose this capability so unless you use something like portinger to manage your containers you just start those on the host operating system and they will be running there and yeah you won't have too much control over them obviously you will have the command line you can log into the host operating system you can start and then stop containers and restore them and so on but pretty much that's it again the whole thing will be invisible for proximals besides the resource usage obviously so if you are okay with these terms then we can jump into the action and we can install and run docker and with it your containers obviously so let's start with that as i mentioned before the proxmox is running on debian linux so the official documentation of docker considering the installation on debian linux part should work although a few modifications are needed so we will just mostly copy paste the commands but some are don't need are not needed for example you don't need to care about old versions because you don't have that also we will be installing with repository but you don't need to care about this first apt-get update comma because proxmox itself keeps the operating system up to date by its automatic package updates so we will just start here you also don't need a sudo because if you are logged into proxmox it's uh via the root user by default in this shell so we will just issue this command first and then we will do all the rest without sudo of course so let's get started normally this whole process shouldn't take long and i also copied the modified commands into the description of the video please note i also span up this part to stop wasting too much of your time so if you just want to check out the output of some of the comments then feel free to pause and that's it as you can see we have successfully executed a simple program running inside docker on the debian x that is running also approximately installation now i understand for many of you this isn't the solution just as i explained at the beginning of the video so what else can we do let me show you something else a different way okay so let's assume the following situation you don't really want to expose your whole proxmox holds to those containers because you know those are running against root processes but you don't really like the idea of a full-blown vm either because those eat a lot of resources to virtualize the whole operating system and of course the underlying virtual hardware so what can you do laxi containers are here for the rescue so i admit that it might sound a bit weird to put containers into containers but trust me it works and it's quite easy so even especially with the ui support for this creating a container and alexi container is quite easy so we will just quickly do that and after that i will explain how these work together with docker setting up an alexi container within proxmox is quite easy it's just as easy if not easier than setting up a vm so just like for a vm where you need an iso image here you will need something that is called a template so templates are stored on one of your storages so you just check your storages and look for one that has this section called cd templates or container templates there you can see different templates with different operating systems or in case of a totally fresh installation thing should be empty so when you click templates here you can search and install existing templates in case of a docker host i usually use debian or ubuntu this time we will go with debian buster because why not so i can just select that click download and it will take a few seconds to download that small template and when it says task ok i can close this one now within based on this template i can create a container now so i just select the node then click create container here i have to set a few options so password this is for logging in to your container by ssh so i just quickly add the password will be the name of your container and within the container the operating system will actually see this value as a hostname so let's let that be test city now a container can be privileged or unprivileged privileged containers can do more stuff but can run malicious code more easily so it always depends on the use case whether you want to use an unprovisioned or privileged container in case of docker some privileged features are needed so you can either go with unticking this and having a privileged container or you can leave it as it is and in that case we will need to set some options later on okay since i prefer to have the privilege container we will go the second way so leave it as it is and click next in case of template here you select the template you have just downloaded so i select that debian one once again i click next rudisk these are the discord operations this operating system with the container will reside now in case of containers or galaxy containers you can mount local folders just like you can do it with docker volumes so you don't need a huge virtual disk instead we will just mount some folders from the host so i will just leave it on the suggested gigabyte this will do nicely as the base operating system storage other than that i can leave all options as they are so click next here you can allocate some cpu cores and set it to two and in case of memory i just reset it to two gigs in case of network i select dhcp because right now i don't want to bother with setting up ip address on gateway and whatnot and and since this installation is a pretty standard one i don't need to change anything with the network here okay dns is just fine the host is set up to use my pi hole as a dns server and that should be also set up to have a dns domain which is in in my case looks like hostname.lan so i click next and the confirmation dialog dialog just shows you the values you have previously selected you can click start after created here to have your container instantly up and running and you can click finish so this will take like roughly a second or a minute or something like that to extract the template set up that small virtual hard disk and then when task okay appears you can close this one okay as you can see now we have our container up and running so in theory you could use right now you could use the container right now to issue linux commands however as you can see the console is empty i mean too empty so this is this looks like a bug uh it happens from time to time with different lens distributions and i couldn't really find out the reason nor all those people on on reddit and various forums and they just keep reporting it but it's still happening anyway there's a workaround for this problem so you just go to options and select console mode and double click here and make sure that you instead of the default you select shell now click ok and here you reboot the container so this will take like two seconds or something like that and when you go back to console you can see now that the console is available and voila you can issue linux comments under your running uh lxc container now we are almost ready to install docker as i mentioned before to execute docker within an alexi container there is a slight adjustment we need to make our container to make docker work to do that you need to need to go to shell once again but not to the shell of the container but instead to the shell of the proxmox node so you select it you go to shell and then we will look for a file with the editor so let's use nano then or you can use vi or whatever editor you have at hand then it should be etc pve which is for proxmox then local that is the storage where the container resides and then it should be lxc and after that that should be the id of your container so in our case it's 100 so i just say 100 and dot com so this is a file and you need to add a single line which looks like the following okay so this is quite simple after that you just save the file and restart your container and now you can proceed with installing docker and the steps are pretty much the same that we have used when we installed the docker on proxmox itself so first of all we will just reboot the container now that the container is up and running we can start with updating and so on in case you run into this kind of problem this is because debian buster is a bit odd so there's a solution for that actually you just need to add an extra parameter for the update command and this parameter will instruct apt to accept any updates made to the repository since the last update as you can see now it's working and at this point we can do the exact same commands so let's just do those quickly as a quick reminder these are the commands we have used during the normal debian linux installation and again these are the ones that you need to execute in the same order please note that the test command that was the last one in the list is missing from here because to test an alexis container we will use a different command instead of the regular hello docker container that is normally used to test docker installation to see whether it's working we will be using that data so netdata is a quick and lightweight analytics tool that attaches itself to your system and grabs a lot of information about your cpu and and memory and network and whatnot and yeah it's a useful tool but the point is that if you're able to run that data now then there's a high chance that pretty much any other container will just run fine so it actually approves us that our docker installation within an unprivileged alexi container is working fine obviously if you don't like the idea of testing with net data you can use any container that comes into your mind and you can just alter the docker run command or even install docker compose and test to your liking as you can see that long command to download and start that data docker image as a container it succeeded we can check it with docker ps it says it's running so we need to try whether it works actually so first i'm just fetching the ip address of the galaxy container it should be this one which is a dhcp allocated ip address and i will need to use the port for netdata that was this one and as you can see it's up and running now let's take a look on proxmox again to see the resource usage and as you can see uh it uses a little bit more than ten percent of the allocated memory it's a miniscule amount of cpu and my new this is only a fraction of the actual system because we only assigned two cpu cores to this galaxy container and as you can see for running net data we could actually gone much much lower with the memory with the disk size with the cpu as well it's worth mentioning that netdata doesn't use data on the disk so this is why the very low disk usage but for example if your container needs to access a set of folders because if there is data from somewhere or actually it needs to write to write some data like downloading stuff or writing to database then you will need to connect storage from your proxmox node to your container and this is done via bind mounts so let's take a look a quick look at blind mounts as the last part of this video working with bind mounts it's quite easy so first of all you need to go to your proxmox host uh to your node and uh assuming yet that you don't have a folder yet that you want to mount up to be visible and accessible with from within the container you need to create one so let's say i'm creating a folder called slash media slash folder okay yeah it's already exist whatever that will be the one that we what we mount up into the container so now i need to edit the configuration file of the galaxy container once again here i need to add an entry that will map the folder to another folder inside the container so this is the name slash media slash folder and this is the name that will exist inside the container so now i need to save this exit and restart the container so i just clicking reboot here yep i want to reboot it while it reboots i go back to proxmox for a second so when it comes to write access to those folders is a bit it comes a little bit complicated because from the operating system's point of view the container is running under a separate user so that means the user does not have right access and so does so doesn't the container either so it means that you need to give write access on that folder right now because this is not the central part of this video and i don't want to waste time on explaining this i will just do a quick hack and basically say that i want that folder to be writable by anyone so i'm just starting uh 777 which is like the guard mode on a folder and this is once again done on the proxmox node so now anybody can write into that folder now i go back to the container which rebooted while we done that and go to yeah at the console obviously so now just let's see the folder yeah it's there so i'm using the touch command to create an empty file let's say hello.text the command succeeded and now the file is there so i go back to proxmox and let's see if i can see the file that's it so basically now we can write into a folder that is located on the proxmox host within the container you can mount this folder into your docker container with the usual dash v command parameter so that's it it means that you can run docker containers within proxmox within galaxy containers and those can write to a system folder those can access resources and yeah mission accomplished okay actually this topic it could be really long much longer i could talk about this topic for hours explaining the nitpicks of this folder management these uh access rights and what else you can do but i really don't want to make the video any longer so let's conclude this for now if you have questions use the comments as usual and i will be happy to answer those so as you have seen most of these solutions are pretty hacky and if you keep wondering whether proxmox is the right tool for you to run docker containers you are absolutely right in my personal opinion if you heavily rely on docker containers then you might be better off with something else but still proxmox is there to use if you want to run a mixed solution like a couple of vms a couple of containers docker containers what not so there you go anyway uh before summing up this video let me ask you a question how do you run software on your setup so what's your story with proxmox with your containers with your vms because well i'm also learning and i'm curious about how other peoples do stuff like that so if you have anything to share please use the comments and while you are at it if you haven't subscribed to the channel yet please consider subscribing it helps me a lot and you will also get notified when i upload new videos so anyway thanks for watching these guys and hope to see you next week next time with another video bye
Info
Channel: The Tinker Dad
Views: 95,707
Rating: undefined out of 5
Keywords: proxmox ve, proxmox tutorial, proxmox docker, proxmox docker container, proxmox docker lxc, proxmox docker lxc vs vm, proxmox docker install, proxmox docker inside lxc, proxmox docker in lxc container, proxmox docker in container, docker lxc, docker lxc proxmox, lxc docker, lxc debian, lxc debian 10, the tinker dad, thetinkerdad, tinker dad, tinkerdad, running docker on proxmox, docker containers in proxmox, docker proxmox no vm, docker containers on proxmox
Id: hDR_1opHGNQ
Channel Id: undefined
Length: 26min 2sec (1562 seconds)
Published: Sat Jan 22 2022
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.