Installing Docker and Home Assistant Container

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
in this video i'm going to show you how to install  docker and home assistant on a linux computer   if you're not sure that installing home assistant  on docker is right for you then you should first   check out a previous video i made which explains  the difference between home assistant operating   system and home assistant container just because  i run home assistant in a docker container doesn't   mean that you need to as well home assistant os  is an amazing piece of kit and i recommend it   to almost everyone who is getting started with  home assistant for their smart home but for me   running docker just makes the most sense i run  lots of different services on docker including   a bunch of services that help me in my smart home  i run piehole for ad blocking frigate for using   ai to detect objects in my security camera streams  zigbee to mqtt for my zigbee devices and many more   i'm going to be creating more detailed videos  about all of these services in the future   so click the subscribe button so you can see when  those videos come out now how do you actually get   docker docker composed and home assistant running  in your house well i'm going to show you this now   hey home automation guy start the show this is  going to be a pretty technical video and there's   going to be a lot of commands to type in and they  may be different for your specific setup to help   with this i've written a blog post that shows you  all of these steps including the commands that i   use which i've linked in the description below so  please treat this video as an overview that shows   the end-to-end process and if you want to play  along at home then fire up the blog post which   will be a lot easier than stopping and starting  the video and trying to read a command line from   the screen before we get started you'll need  a computer preferably running linux that is   connected to your home network i use my intel nuk  mini computer and i have ubuntu linux installed on   it but you can use any old pc or laptop that you  have lying around at home you'll also need to be   able to ssh into this computer with a user account  that has sudo or root access to get started we'll   need to ssh into the linux computer so that you  can type the setup commands into the command line   before you do that i suggest you go and get  yourself a cup of tea or coffee because it's   going to take some time there's a lot of waiting  around as things download and get installed cheers   here on the screen you can see i've just  sshed into my linux server and i've also   got the docker documentation up installing  docker is mainly just copying and pasting   commands from the docker documentation into your  ssh terminal and we're going to be doing that now   i've linked all of these in the blog post which  i've put in the description below so you can do   this at your own leisure so docker is currently  free if you're running it for personal reasons   or in a small business sort of environment if  you exceed any of these particular parameters   then you'll have to pay for a license it's  incredibly unlikely that you're hiring this   many people in your house or you're turning  over that much if you are turning over that   much maybe you should hire me to set this up for  you as i mentioned before you can install docker   on mac windows but here i'm going to be using  linux i've specifically chosen ubuntu it has   the most green text that means it has to be better  right but if you want to install this on any other   flavor of linux all of the links and all of the  documentation you need can be found here as well   i'm running ubuntu 20.04 as you can see in the  terminal here and that's supported by docker   so let's get started first we're going to check  if there are any old versions of docker already   on the linux server and we're going to remove  them if they're there here you can see in mind   there aren't any because it's a fresh version of  ubuntu now i'm just going to be blindly copying   and pasting commands from the help files  into my ubuntu ssh session i would highly   recommend that you don't do this from places  that you don't trust the docker website is a   very reputable website so i'm not worried about  pasting anything malicious in but you should be   very careful if you're just randomly copying and  pasting things from someone's blog for example   so the first thing we're going to do is check  for any updates to the system we always want to   be installing things on top of a fresh operating  system and you'll now know why i suggested you   get a cup of tea a lot of these takes a lot  of time downloading and installing packages we're now going to be installing a  bunch of dependencies that docker needs now we're going to add the official pgp key and add the repository where you can download this  stable version of docker i'm going to always use   the stable version but you can also change this  to use experimental or beta versions if you'd   like now i don't really know what a lot of these  commandlets do i don't know how they work but i   know that when i do them they end up installing  docker and that's what we're trying to do   if anything prompts me to click yes i'll click yes technically now install docker so  what we're going to do is download a   hello world test image to make sure  that everything's working properly if you can see this hello from docker output  message that means everything's worked and   installed properly from time to time you  should make sure that your operating system   and any of the packages you've installed  are updated and running the latest version   you can just copy and paste this command in maybe  once a week or once a month to keep everything   up to date you can see that nothing really  happened here because we've just installed   it so it's running the latest version so now  that we have docker installed and running we're   going to want to install docker compose this page  gives you a bit of an overview about what docker   compose is and how it works but we're going  to skip straight to the installation section   before we can install docker compose we need to  make sure that we've met all of the prerequisites   we've got a linux server installed and  we've installed docker engine on it   but we also want to make sure that we can  run docker compose as a non-route user so   we're going to follow these steps now first  thing we want to do is create a docker group   but that already exists it was probably created  when we installed docker now we're going to add   the user account we're logged in as into that  docker group after we've made changes to user   or group permissions it's best practice to log out  and log back in again so let's do that again now the permissions should now be updated now we can  run that hello world docker container again to   make sure that everything's still working you  can see by the output message that it's working   great now that we've got docker and all of our  prerequisites set up it's time to install docker   compose itself this is going to be another  one of those exercises where we just copy and   paste commands from the documents into the ssh  window we're going to download docker compose   and install that we're going to make some changes  to permissions and files and finally we can test   whether or not docker compose is installed  properly by telling it to output the version   so we now have the docker engine and docker  compose installed and running on our system   it's time to actually set up some of our own  containers the first container that we want   to set up is called portainer portena lets  you manage and look at all of your docker   containers through a handy web interface i  find it just much easier to use than using   the command line but you can do it all from the  command line if you wish the first thing we need   to do is create that docker compose yaml file  that i was talking about in my previous video   you can see here we're creating a version  3 version of the docker compose file   the next key you can see there is services  each one of the services underneath this area   is a different container the first container  i'm going to be setting up is called portena   you set the name of the container you then tell it  which docker image you need to download the docker   image contains all of the information it needs  to run that application basically everything that   lives inside the container we're going to map  port 9000 through to port 9000 on the container   and we're going to mount two different data points  from our host operating system into the container   the first one points it to a series of docker  configuration files that way i can understand   which containers are loaded and which ones are  running the second thing is the data for pertainer   itself i like to keep all of my container data  underneath the slash opt directory why do i do   that because my met kieran who knows lots about  linux and unix told me that's where it should live   you can put it wherever you want as long as  you have the right permissions and it makes   sense for you here we can see that underneath  the slash op directory we will be creating a   new directory called portena and then after the  colon we can see that it will map to the data   directory within the container itself you can  always map different directories into different   parts of the container and that is where the  configuration information will stay once you   restart or recreate that container it will  remap that directory it'll be able to access   all of the files and configuration that it had  before the container was deleted and recreated   that means you won't lose any of your settings  when you upgrade versions or recreate containers   once we're happy with the contents of our docker  compose file we're going to create a new docker   compose.yaml file using the nano text editor on  our linux server again you need to create this   in the slash opt directory try and keep all your  files in the same place then just copy and paste   the contents into that file press control x  to quit nano and then yes to save that file   if we do a directory listing on the op directory  you can now see that dockercompose.yaml file   has been created you now need to start docker  compose from within the directory that contains   your docker compose yaml file if you try and run  it from a different directory it will say hey i   can't find the docker compose file you need to  make sure that you name it correctly as well   we run docker hyphen compose space up which will  bring up all containers inside that file we add   the hyphen d switch to run them in detached  mode which means they run in the background   it will now download all those containers  we've specified in the configuration file   including any dependent piece of information  that it will also need to run you can see that   it's creating the portena container and that it's  done if we now do a docker container list you can   see those containers are actually running so  now let's switch back to our web browser and   navigate to the ip address of our linux server  with colon 9000 at the end to go to port 9000   you can see this has brought up the portena web  interface you'll need to create a username and   password you don't need to do this every time this  will be stored into the opt folder of your host   system so when you recreate the container it will  remember this username and password going forward   you can see that the instructions are reminding  us to configure the mapping for that docker file   that we said before we switch back to our  docker compose file you can see it matches   the instructions that we were given there and  that's why we put it in there in the first place   this allows it to read the docker container  information so you can now see we have one stack   of containers and if we click on that and we view  those containers you can see there are actually   three containers here two of them happen to be the  hello world test containers that we created before   so they're stopped which is why they're not  listed when we run the docker container ps command   however they still exist in the system so we can  simply tick those and click remove again you can   do this through the command line if you want but  i find it far easier to do this through portainer   itself if we click on the portena container we  can see lots of information about it including   any of the cpu and memory usage we can access  any of the log files that have been output by   this configuration and this is really useful  for troubleshooting anything you've got going   on in your containers so now that we have docker  running with portena on a container it's time to   install home assistant through docker as well  the easiest way to do this is to go to the home   assistant website go to the installation  section and scroll down to the linux area   once you're in the linux area we need to scroll  down again to the docker area here you can see   you can install home assistant using docker if  we scroll a little bit further you can install   it using docker compose as well what i'm going to  do is copy and paste the home assistant section of   the sample configuration file into my own docker  compose yaml file as with all yaml files make sure   you've got your indenting correct just like the  portana configuration area we're going to name our   container we're going to make sure it's pointed  to the right image and then we're going to map   through a directory from our host computer which  contains our configuration to the config area   within that container i'm just going to update the  path to your config to slash opt home assistant   config which will then map into the slash  config folder within the container itself   i'm going to copy that out i'm going to go back  to my ssh session i'm going to edit that docker   compose yaml file using nano i'm just going to  paste it into the bottom once it's pasted i'm   going to press ctrl x to exit nano click yes to  override that file every time we make changes to   the docker compose yaml file we need to rerun  the docker hyphen compose command with the up   and hyphen d switches this will recreate any  containers that have changed but you'll see that   it won't touch the portena container because we  haven't actually made any changes to that and this   is where you should be thankful that you've had  a cup of tea because this bit will take a while when it's finally finished you can run the  docker container ls command again and you can   see we now have two containers running if we do a  directory listing inside the slash opt directory   we can see there's two new directories created  one for pertainer and one for home assistant if   we navigate into the home assistant directory we  can see that there's a configuration directory   and we go into that and we create a directory  listing you can see all of the home assistant   files that you're expecting now these are stored  on the host operating system so if we recreate   the home assistant container upgrade it to a new  version all of our home assistant settings will be   saved and safe now we switch back to portena and  you can see there are two containers now running   one for portena and one for home assistant  if we go into the home assistant container   we can see any of the log files which is  great for troubleshooting automations or   if homer system won't load up we can see  the cpu and memory usage over time as well   now here's the best bit about portena you can  create a shell directly inside that container   what that means is you can effectively ssh  into that container and run any commands   that you need to this is really great for doing  troubleshooting or advanced cleanups you shouldn't   have to go in here but it's a lot easier than  trying to do it through the docker ps commands   so portina tells us that home assistant is running  in a container we should now be able to go back to   the same ip address but to the home assistant port  which is 8123 we can see the welcome wizard for   home assistant follow the rest of the setup wizard  and you now have home assistant running inside a   container just like you would with any other  home assistant installation unfortunately with   a container install you can't manage everything  inside the home assistant user interface like you   can with the operating system install you need  to open the web interface for all the services   you run in docker containers in different browser  tabs or windows wouldn't it be way better if we   could just access these web interfaces directly  through the home assistant navigation menu   well you actually can do that by using something  called iframe panels this is something that allows   you to pipe through a web page or user interface  from another place directly into home assistant   to do this we need to add some lines to the  homeassistantconfiguration.yaml file like this   first you create a panel iframe key and under that  we're going to create a key for portena this will   allow us to access our portena web interface from  inside the home assistant we give it a title which   is what will appear in the navigation menu text  you add the url of the pertainer web interface   into the url section and you can also add any home  assistant material design icon here i've chosen   the docker one depending on the service i may also  set the require admin option to true which means   this menu item is only shown to users with home  assistant administrator permissions we now need   to add this to our homeassistantconfiguration.yaml  file so we'll go back to our ssh session and we'll   use the nano text editor to edit the file we'll  paste in that iframe configuration at the top of   the file press control x to quit and y to save  the file we now need to restart home assistant once it's restarted you'll see a new item on the  left hand navigation menu called putana with our   docker icon by clicking on that link you'll see  it load up portena directly inside home assistant   i do this with almost all of my home automation  docker containers and it makes it really easy   to manage both home assistant and non-home  assistant services from one single place   who needs a supervisor or add-ons eh don't  worry i've included all of the steps you   need to make this happen in the companion blog  post which i've linked in the description below   so there you go you've now got docker  running on your computer and you can   use portana to manage those containers in  a graphical user interface you've also got   home assistant installed and ready to go i use  docker to run loads of my smart home services   and i'm going to be creating detailed videos  about all of them if you want to know more   about what these services are and why i  use them then hit the subscribe button so   you'll know when those videos are released  and together we can make your home smarter
Info
Channel: Home Automation Guy
Views: 152,856
Rating: undefined out of 5
Keywords:
Id: S-itdbqwj4I
Channel Id: undefined
Length: 16min 55sec (1015 seconds)
Published: Wed Feb 23 2022
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.