How To Run Home Assistant Container With Docker Compose On a Raspberry PI

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
foreign [Music] folks and welcome back and in today's video we'll be looking at how you can actually run the home assistant container on a server now for me right now my server is a Raspberry Pi 4. so in this video I will be showing you how you can actually have the Raspberry Pi running Ubuntu then we will install Docker and then finally have Docker compose which will start up the home assistant container now if you are new to home assistant and if you just want to get started off with it then I recommend this particular video that I have made wherein I show you how you can install home assistant OS on an SD card and then you can insert that SD card into the Raspberry Pi and connect the Raspberry Pi to the router using the Lan cable you can skip the part about the Wi-Fi setup over there now in this video let's look at how we can actually set up the Raspberry Pi with Ubuntu and then install Docker in a step-by-step guide so with this let's get started now if you already have a server or you already have a machine on which you have some kind of a Linux desktop running then you can move to the next chapter wherein I will show you how you can actually install Docker and then Docker compose and then start our home assistant container now let's look at how we can actually install the Ubuntu OS on a Raspberry Pi so for this what I'm going to do I'm going to go to this Raspberry Pi Imager and you have this raspberry pi.com software in which you can download this particular image so now you have an image of the Ubuntu OS because I'm running Ubuntu on my system right now you can download it also for Windows as well as for Mac now I have this already installed on my system so I'm going to open this and now what I'm going to do is I'm going to choose the OS now this is the OS that you want to choose in order to write on the server right so I have an SD card installed onto my machine now what I'm going to do is I'm going to select this other general purpose OS now in this section you will find the Ubuntu OS itself so let's click on this and I'm going to select Ubuntu here now after selecting this you have various versions here like the Ubuntu desktop Ubuntu server and many other things so what I'm going to do now is I'm going to select the Ubuntu Server you can also use Ubuntu desktop but since I'm using a Raspberry Pi this desktop version will have a lot of things like the visual stuff through which you can actually view the Ubuntu desktop itself so you can then connect this Raspberry Pi to an HDMI port and then afterwards have a monitor connected to it and you can work with that also this is also fine actually but what I'm going to do I'm conserving a lot of resources by installing only the server wherein I don't have any kind of a visual view of the desktop of Ubuntu but I will only connect it to the server and then use as much as power from this Raspberry Pi so that's the reason I'm going to use the server version here now I'm going to use the server version which is of 64-bit and this is for Raspberry Pi 4. so you can see Raspberry Pi five three four and I'm going to select this 64-bit one so let's select this and then I'm going to select the storage here now I have this 32 GB which has been mounted on my system now and I'm going to select this particular SD card make sure that this is exactly the SD card that you are trying to write on and not your home system okay so with this this part is done right now when I install Ubuntu right on my Raspberry Pi how does it actually connect to the Wi-Fi now this image actually provides a convenient way to do this so what I'm going to do is I'm going to click on this particular gear icon and here you can set a lot of things then the next thing that I'm going to do is I'm going to enable SSH so what we are going to do is actually we are going to connect to our Ubuntu server using SSH so SSH is a mechanism through which you can connect to a remote server or basically for me it is a local server using command line okay this will enable SSH for us next what I'm what I'm going to do is I'm going to give it a username so I'm going to give this a username and I'm going to give it a password followed by this I'm going to give it a wireless connection now this is important because when the Raspberry Pi boots up it actually has to connect to the wireless network right so then I can connect it on my machine using SSH so here I'm going to set the SSID for my Wi-Fi as well as a password now this is already been stored so I will say save and and I'm going to now start writing the Ubuntu OS this will ask me for the password just to confirm that I want to start writing and now this is going to actually start downloading the Ubuntu OS for Raspberry Pi and then start writing so this will take a bit of some time so let's actually pause the video here and reach once it's done so as you can see now the Ubuntu OS has been written on my SD card now what I'm going to do is I'm going to actually remove this SD card and I'm going to put it on my Raspberry Pi that's the SD card that I have I'm going to plug it into my Raspberry Pi now what I'm going to do is I'm going to actually start this particular Raspberry Pi so I connect this here switch it on and there we go so the Raspberry Pi is right now running now I'm going to wait for it to actually connect to the Wi-Fi network so give it some time maybe a few minutes and this will now actually connect to the Wi-Fi network now so in the meantime let's actually open our terminal so I have this different terminal called as hyper which I use but you can use your normal terminal like like terminal here you can use this one I'm using this modified version called as hyper now I have this terminal now here what I'm going to do is I'm going to actually scan my network now to scan my network on the Ubuntu system you have this uh you have this command called as ARP scan and using this ARP scan you can actually find out your network interface for your machine so this is my network interface and using this I'm going to actually now search for the Ubuntu Server which is connected now here if you see I have actually two Raspberry Pi so let me run this command again and if you see here I have one Raspberry Pi here which is running on 158 now this is actually my Raspberry Pi server which has Ubuntu already running on it and I'm running the home assistant container on this so I'm controlling my entire home using this container on this particular Raspberry Pi now this is the new Raspberry Pi which I've just connected and it's already up and running with connecting to the Wi-Fi itself Now using this particular IP we are going to do in SSH so what I'm going to do is SSH amrut at the rate and I'm going to specify the IP address now this is the username and password that we had set it here so if I click on this pack again and scroll back here this set username and password and I'm going to use this username which is amrut and at the rate and I'm going to specify the IP address to which I'm going to connect to the server and the password is a password I'm going to use now next so when I press enter here it will ask me for the password and I'm going to enter the password now so with this now we are actually logged into our server so now I'm connected to the Raspberry Pi server and now we are going to actually start installing Docker so for this what we are going to do is we are going to go to Google first we're going to type install Docker engine and this result that you see from docs.docker.com this one we are going to open now now this is the official site from Docker so make sure you come to this site exactly and not any other site for installing Docker because this is for security reason that you install exactly from the official documentation now since we are actually using the one from Ubuntu we are going to go to this Ubuntu section and we are going to actually now start installing Docker so now the installation method that you can see here first of all it will ask me to do these stuffs now a lot of these commands that you can see are pretty much cryptic and it's not easily understandable so bear with me that you can run this particular commands and this will do these things by yourself usually you should not run scripts from different websites but this website is an official one there is no problem from running scripts from here so what I'm going to do is I'm actually now going to copy this from here and I'm going to go to my terminal and I'm going to paste them so it's going to be asking me for a password now this will take some time so let's actually pause this here so now the first set of commands have been run we are going to add the official Docker gpg key so let's copy this and also paste this here and next we are going to do is we are going to also copy this and we're going to paste this here now with this actually we have set up the repository for actually downloading.com we haven't installed Docker yet so now we are going to actually start installing Docker so first we're going to copy this command here and we are going to paste this here this will take some time and then finally we will install now to Docker engine and along with this the entire Docker compose plugin also so now you don't have to install doco compost separately now with this we will now install Docker as well as Docker compose now you want to see where this part is this is the part wherein we are going to install the Community Edition for Docker as well as we are going to now install the docker compose plugin along with it okay so what we're going to do is we are going to now copy this entire command and we are going to paste this here say yes to this and this will now start installing Docker engine for you along with Docker compose so this will take some time for the installation to happen so sit back grab a coffee and then wait for it to finish it with this now we have actually installed Docker along with Docker compose now to test this what we're going to do is we're going to run this Hello World stuff so we're going to copy this here and we are going to run this now now this will actually pull the docker image for hello world and with this actually you will see this particular message hello from Docker if you get this particular output that means your Docker installation is successful now what we are going to do is we are going to check if Docker compose is also present so what we're going to do is docker compose LS LS means list now what you see here is that I'm getting a permission denied stuff now why is this permission denied because this installation has been done using the root user now let's see how you can actually do this so that the normal user that I have right now can access the docker engine itself so now to allow this user to actually access Docker we need to actually provided some permission so what I'm going to do now is let's go back to this browser here and then in this section here called as post installation step I'm going to click this and here you can see manage Docker as a non-root user so I don't want to run Docker in the root permission I'm going to run it using normal permissions so for this let's actually copy this particular command and run this and paste it okay now we have this now we're going to add the user to the docker group now with this we have actually added the user to the docker group now the next step that it says is that we need to log out so what I'm going to do is I'm going to log out saying exit and I'm going to log in back again with this so I'm going to login back here and now after login let's see if I can actually run the hello world so let's copy this and run this here so now you can see I can run the docker image without running sudo in front so we don't need to give it root permissions to actually run Docker now let's actually do this for Docker compose so Docker compose LS and as you can see this command is also running all well so cool we have now installed Docker on our system we are now able to actually now run Docker images on our system and also we don't require any kind of root permissions so this is the way actually you can install Docker now what we are going to do is now we are going to do the most important stuff that is install home assistant now for this what we are going to do is we are going to go to the home assistant site and then we are going to go to the installation section so we are going to go here now if you scroll down you will find various options here and what we are going to do is we are now going to go to this section that is Linux and wherein it says that I can install home assistant container so let's open this here and then if you see here this is the place wherein we have our Docker compose file so what am I going to do is I'm going to copy this entire thing from here okay and so now to create a file we are going to use this VI editor so space VI and we are going to call this as docker compose dot Yammer okay so this is the file that we're going to create and we are going to paste this now okay so let's open this file I'm going to press I to start in the insert mode so in this I can actually now type in something or paste things so I'm going to paste this here so now what it is doing here let's actually understand this now this is saying that it's going to use the docker compose version 3 and I'm going to run the service called as home assistant now this is the service that I have this service container is going to be called as home assistant and we are going to make use of the stable version of Home assistant Docker image so basically this is going to actually now download the image which is the stable version for running the home assistant container next if you see there are two parts here been configured one is the part to our config so this is actually the configuration for our home assistant we don't want this configuration to be present inside the container because if we restart the container we will lose all this configuration so we want this configuration to be present on our system and not into the home assistant container but what we are doing is using this configuration we are actually mounting our system path onto the home assistant container simpler terms is that if you restart your home assistant container your configuration files which was there inside the home assistant container will not be lost they will be still present on your system if you change this particular image also you will not lose this particular configuration now if you see I need to actually specify this particular path so this part does not kind of exist right now right so we are going to create this path but let's actually look at the other options so we are going to give this a privilege mode and we are going to allow it to access the host Network now why we want to allow this to access a host network is so that this container can then actually scan everything on our Local Host Network so on this network whatever devices that are there home assistant will be able to actually discover them okay so now actually to save this particular file we're going to press Escape then we're going to press colon and then we are going to press w means right and Q to quit so this will actually now write and quit so we have the file written here okay now what we are going to do we are going to create One Directory okay called as config okay now with this directory this is the directory on my server right now now I need to mount this particular directory onto the home assistant container so what I'm going to do is I'm going to go inside this config directory and type PWD so when I type PWD it will give me the entire path from the host so this is the path of this particular config folder that I have and now what I'm going to do I'm going to come out of this I'm going to say win and I'm going to edit the docker compose file now here in the volume section I am going to remove this part here and I'm going to press insert that is I to insert and then paste this here so if you see here what this thing says is that I'm going to map this particular path on my system on to this particular path in home assistant so home assistance config path is at slash config and this particular path I'm going to map it to that so my system path will be mapped to this particular location with this actually we are actually done with our Docker compose setup and we also done with our home assistant setup so I'm going to write this changes to the file and now I'm going to run Docker compose up this will now actually start this particular Docker compose file so let's run this so right now it's actually downloading the home assistant Docker image and let's wait for it to start up so now you see it's actually starting up home assistant so it created the container from the image that you downloaded and now it's actually starting up home assistant now to access this particular home assistant what we're going to do is we are going to actually go to our browser and remember this particular IP address that we used we are going to use that same IP address to now access the home assistant so let's start with 192.168 and 130 was the IP address on which my Raspberry Pi is running on and I'm going to use the port 8123 so this is the home assistant port on which actually this particular container is running so home assistant runs on 8123 and we're going to use this so let's start up and as you can see we are actually now accessing home assistant from the docker image which is running on our Raspberry Pi so this is the way we can actually run the home assistant container it using Docker and then access it via this particular Port so now with this we are going to set up our home assistant so we're going to give it the name and we are going to give it a password and we're going to confirm this so let's create this account and then after specify your country your language and press next and then after that you can allow for anonymized statistics to be shared I'm right now not allowing them and then afterwards as you can see it has already detected a lot of things on my network so it has detected my Google home here this is an Android TV that is actually running you can do more Integrations by clicking on this and you can add Integrations here so with this actually now I will press finish and voila we are actually right now in home assistant which is actually running as a home assistant container on my Raspberry Pi and now the advantage of doing this is that I can actually run many applications on my Raspberry Pi also so now I can install yet another application called aspotena so using potena I can actually manage a lot of my Docker images that I'm running on my Raspberry Pi and this is something that I will do it in my next video so I will show you how you actually run a doco compose of potena and then one interesting thing is that we will then access it using a menu item here make sure you subscribe to this particular channel to see how you can actually do this and manage all your Docker containers using potato and I will show you how you can actually SSH into your container how you can actually manage top your container restart your container all of this stuff using the protein itself now this command that we ran to actually run the container if you see in this terminal here it is actually currently running so if I actually stop this particular command this will also stop my home assistant so if you see it has lost the connection on my browser because the home assistant is down now to actually make this command run in the background what you would have to do is you would have to type Docker compose up space minus D and this will run in the detached mode this detach mode will cause this particular Docker compose command to run in the background so when I press enter as you can see I got back to the terminal and now this is actually running in my background so let's give it a few seconds and refresh this so as you can see now I'm able to actually access home assistant back again and I'm going to enter my username and password so with this I'm able to now access home assistant again and the command is now running in the background now in case if any time you want to stop this particular container you want to take it down what you need to do is instead of pressing Docker compose up we're going to type Docker compose down but make sure you are in the exact same directory where you have this particular Docker compose file even the docker compose up a command you have to run it exactly in the directory which contains a Docker compose file then only this thing will work so right now I'm in the directory which contains a Docker compose file so I'm going to run Docker compose down and now this will actually stop my home assistant container so now this has actually stopped home assistant I can start it back again by saying Docker compose up minus d and this will start home assistant back again give it a few seconds and here we have we have the home assistant up and running back again so with this we learned a lot we learned how we can install the docker engine we actually saw how we can write the docker compose file in this terminal here and then afterwards we actually started the docker compose file to actually start this particular home assistant remember we had mounted this particular host part called as config onto this Docker container right let's look at the contents for this so let's clear this up and in my current directory right now remember this folder that we had created config let's go inside this so CD config and I'm going to press LS now these are the configurations that home assistant has actually created for us now the main file for US is actually this configuration.yaml we can open this using way VI configuration.yammer and this actually now contains all our configurations for home assistant we'll be doing a lot of edits in this configuration and we will see how we can and customize our home assistant to actually do a lot of Integrations so I'm going to press Escape colon and queue and exit from here so I hope this step by step guide helped you actually to see how you can actually run the home assistant container on any Ubuntu Server now I'll be making more such kind of videos wherein I'll be exploring a lot about home assistant so make sure you subscribe to this particular Channel and give this video a thumbs up for more such videos to come till then take care and see you in my next one thank you
Info
Channel: Smart Home Circle
Views: 3,695
Rating: undefined out of 5
Keywords: home assistant, smart home, home automation, home assistant docker, home assistant setup, docker compose, home assistant docker ubuntu, home assistant docker update, home assistant docker compose, docker compose yml, docker compose file, docker compose tutorial, docker compose volumes, home assistant raspberry pi, home assistant guide, home automation ideas, home automation project, raspberry pi 4 projects, Home Assistant WiFi setup, iot devices, home Assistant container
Id: Cvjc66-mkFo
Channel Id: undefined
Length: 25min 11sec (1511 seconds)
Published: Thu Jun 29 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.