From 9208d8b761c91796826bb3fb7a5885c350bf46d9 Mon Sep 17 00:00:00 2001 From: Mathieu Maret Date: Tue, 10 Jan 2017 20:45:14 +0100 Subject: [PATCH] Howto start hass with docker and systemd (#1746) Add unit example to start hass with docker using systemd. Useful if you have several config with several user --- .../autostart-systemd.markdown | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/source/getting-started/autostart-systemd.markdown b/source/getting-started/autostart-systemd.markdown index 4f2aa50f747..37a001d5582 100644 --- a/source/getting-started/autostart-systemd.markdown +++ b/source/getting-started/autostart-systemd.markdown @@ -52,6 +52,25 @@ ExecStart=/srv/hass/bin/hass -c "/home/hass/.homeassistant" WantedBy=multi-user.target ``` +If you want to use docker, the following template should work for you. + +``` +[Unit] +Description=Home Assistant +Requires=docker.service +After=docker.service + +[Service] +Restart=always +RestartSec=3 +ExecStart=/usr/bin/docker run --name="home-assistant-%i" -v /home/%i/.homeassistant/:/config -v /etc/localtime:/etc/localtime:ro --net=host homeassistant/home-assistant +ExecStop=/usr/bin/docker stop -t 2 home-assistant-%i +ExecStopPost=/usr/bin/docker rm -f home-assistant-%i + +[Install] +WantedBy=multi-user.target +``` + You need to reload `systemd` to make the daemon aware of the new configuration. Enable and launch Home Assistant after that. ```bash