1、硬件:Orange Pi one
2、系统:Linux 5.4.65-sunxi(docker安装需要3.10.0及以上版本的linux内核)
sudo apt update
sudo apt install docker.io
3、验证docker是否安装成功
root@orangepione:~# sudo docker --version
Docker version 20.10.12, build 20.10.12-0ubuntu2~18.04.1
1、搜索docker镜像
docker search home-assistant
上图中排在第一的 homeassistant/home-assistant 它的星标最多,我们选择下载它
2、下载镜像
docker pull homeassistant/home-assistants
3、查看下载的镜像
docker image ls
1、启动
docker run -d --name="hass" -v /path/to/your/config:/config -v /etc/localtime:/etc/localtime:ro --net=host homeassistant/home-assistant
注意:
1. /path/to/your/config 指的是你本地的HA配置目录,用来在本地存放你要运行的 HA 配置,比如 configuration.yaml 等配置文件
2. :/config 这里的config指的是你 docker 镜像中HA的配置目录,如果/path/to/your/config 这个目录在本地存在,则HA启动时会读取本地的配置,入伏哦/path/to/your/config 在本地不存在,则读取docker镜像中HA的配置目录
2、查看运行状态
docker ps
有创建容器时指定的name的记录表示已经运行成功
直接打开 192.168.31.112:8123 进入配置你的 Home-Assistant 吧(192.168.31.112设备的IP地址)
3、启动/停止容器
## 启动
docker start hass
## 停止
docker stop hass
1、将docker服务加入开机自启动
#加入自启动
systemctl enable docker
#查看是否加加入自启动成功
systemctl list-unit-files | grep enable
2、在容器创建后通过update命令实现容器的开机自启动
#查看容器ID
docker ps
#设置开机运行
docker update --restart=always 容器名称(或者容器ID)