Bookmark

Run Home Assistant in Docker

Home Assistant is an open-source home automation platform that works well on a Linux server or HomeLab. This article adapts the Docker-based setup and stores the application configuration in a dedicated directory.

Source reference: i12bretro – Running Home Assistant in Docker . The original video belongs to i12bretro on YouTube .

Youtube video player

Install Docker on Linux

On the Linux host, run the following commands to install Docker:

1
2
3
4
5
6
7
sudo apt install apt-transport-https ca-certificates curl software-properties-common gnupg-agent -y
curl -fsSL https://download.docker.com/linux/$(awk -F'=' '/^ID=/{ print $NF }' /etc/os-release)/gpg | sudo apt-key add -
sudo add-apt-repository "deb [arch=$(dpkg --print-architecture)] https://download.docker.com/linux/$(awk -F'=' '/^ID=/{ print $NF }' /etc/os-release) $(lsb_release -cs) stable"
sudo apt install docker-ce docker-compose containerd.io -y
sudo systemctl enable docker && sudo systemctl start docker
sudo usermod -aG docker $USER
su - $USER

Run the Home Assistant container

  1. Create a directory for the configuration:
1
2
mkdir ~/docker/home-assistant -p
sudo chown "$USER":"$USER" ~/docker -R
  1. Run the container. Change TZ to the actual local timezone if needed:
1
2
3
4
5
6
7
docker run -d --name home-assistant \
  --privileged \
  -e TZ=Asia/Ho_Chi_Minh \
  -v ~/docker/home-assistant:/config \
  --network=host \
  --restart=unless-stopped \
  homeassistant/home-assistant
  1. Check the container with docker ps and wait for the first initialization.
  2. Open http://DNSorIP:8123/.
  3. Create the administrator Name, Username, and Password.
  4. Name the installation, for example Home.
  5. Click Detect to set the location.
  6. Verify the Unit System and Currency, then click Next.
  7. Select any anonymous data to share with the Home Assistant development team.
  8. Click Finish to open the main interface.

Note: --network=host gives Home Assistant direct access to the host network namespace, which can help with device discovery but also increases the container's network scope. Use it only on a host you control and protect the Web UI with a trusted network or an appropriate reverse proxy.

Source and video


0 Bình luận

Góp Ý / Bình Luận / Đánh giá