【软路由】esxi + ubuntu + docker 搭建 HomeAssistant

一、安装ESXI 6.7

1.安装过程一路下一步就可以

2.设置IP

F2进入设置:
20210328143543340
选择 “Configure Management Network” 然后 IPV4 configuration设置IP地址:
2021032814393520
设置完IP,用浏览器输入对应IP进行访问

3.开启SSH

选择 “Troubleshooting Options” 然后 “Enable SSH”
20210331101120225

4.激活

主机->管理->许可->输入 0U0QJ-FR1EP-KZQN9-J1C74-23P5R

二、安装ubuntu系统

下载服务器版本进行安装 https://ubuntu.com/download/server

1. 设置 root 用户密码

sudo passwd root

 

2. 开启root ssh登录

修改配置文件 vim /etc/ssh/sshd_config

PermitRootLogin prohibit-password
改为
PermitRootLogin yes

 

重启生效:reboot

3.设置时区

查看当前系统时间 date -R

运行 tzselect
依次选择:亚洲 Asia、中国(China)、北京(Beijing)
复制文件到/etc目录下 cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
再次查看时间date -R,已经修改为北京时间

修改时间
sudo date -s MM/DD/YY //修改日期
sudo date -s hh:mm:ss //修改时间

三、安装homeassistant

1.安装docker

docker 官网
先更新 apt-get update
如果有安装过,先卸载 apt-get remove docker docker-engine docker.io containerd runc
使用shell 脚本进行安装,等待越一两分钟

 curl -fsSL https://get.docker.com -o get-docker.sh
 sudo sh get-docker.sh

 

运行 docker run hello-world 测试是否安装成功,成功会有如下打印信息

root@ubuntuha:~# docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
b8dfde127a29: Pull complete 
Digest: sha256:308866a43596e83578c7dfa15e27a73011bdd402185a84c5cd7f32a88b501a24
Status: Downloaded newer image for hello-world:latest

Hello from Docker!
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:
 1. The Docker client contacted the Docker daemon.
 2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
    (amd64)
 3. The Docker daemon created a new container from that image which runs the
    executable that produces the output you are currently reading.
 4. The Docker daemon streamed that output to the Docker client, which sent it
    to your terminal.

To try something more ambitious, you can run an Ubuntu container with:
 $ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker ID:
 https://hub.docker.com/

For more examples and ideas, visit:
 https://docs.docker.com/get-started/

 

2.安装 homeassistant

官网安装方法

运行以下命令,配置将会储存到 /root/homeassistant 目录

docker run --init -d \
  --name homeassistant \
  --restart=unless-stopped \
  -v /etc/localtime:/etc/localtime:ro \
  -v /root/homeassistant:/config \
  --network=host \
  homeassistant/home-assistant:stable

 

运行后,等待安装,完成后用浏览器打开 http://<host>:8123 即可进入登录界面

3.更新 homeassistant

# if this returns "Image is up to date" then you can stop here
docker pull homeassistant/home-assistant:stable

# stop the running container
docker stop homeassistant

# remove it from Docker's list of containers
docker rm homeassistant

# finally, start a new one
docker run --init -d \
  --name homeassistant \
  --restart=unless-stopped \
  -v /PATH_TO_YOUR_CONFIG:/config \
  -v /etc/localtime:/etc/localtime:ro \
  --network=host \
  homeassistant/home-assistant:stable

Related Post

发表回复