本文最后更新于 833 天前,其中的信息可能已经有所发展或是发生改变。
众所周知 Docker是一种对于运维来说很方便的工具
Home Assistant的安装在docker容器上,也更加方便和快捷
本文将从docker小白的眼里去从0了解 docker在linux(指GNU/debian或Ubuntu)的安装和compose的设置,并且由此了解容器持久化和容器镜像的内容。
1、安装Docker
首先 我们如果使用的是新安装的debian
那么
$ sudo apt-get update
//添加docker的GPG钥 Add Docker repo GPG key
$ sudo mkdir -p /etc/apt/keyrings
$ curl -fsSL https://download.docker.com/linux/debian/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
//添加docker库到apt管理器 Add Docker to Apt
$ echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/debian \
$(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
随后安装docker容器
$ sudo apt-get update
$ sudo apt-get install docker-ce docker-ce-cli containerd.io docker-compose-plugin
验证
$ sudo docker run hello-world
看到反馈即为成功
2、安装Docker compose
$ sudo apt-get update
$ sudo apt-get install docker-compose-plugin
3、安装Home assistant
拉取docker
docker pull homeassistant/home-assistant
编写compose
PATH_TO_YOUR_CONFIG改为你要的目录
volumes即为永久数据卷
使用nano创建docker-compose.yml
version: '3'
services:
homeassistant:
container_name: homeassistant
image: "ghcr.io/home-assistant/home-assistant:stable"
volumes:
- /PATH_TO_YOUR_CONFIG:/config
- /etc/localtime:/etc/localtime:ro
restart: unless-stopped
privileged: true
network_mode: host
运行docker
docker compose up -d
随后访问
http://your_ip:8123
ref:
https://www.home-assistant.io/installation/linux