Docker start first time

sudo docker run --init --restart on-failure -d --name="home-assistant" -v /home/bnp/homeassistant:/config -v /etc/localtime:/etc/localtime:ro --net=host -v /run/dbus:/run/dbus:ro homeassistant/home-assistant


sudo docker restart "home-assistant"


sudo docker stop "home-assistant"
tar -cvf homeassistant.tar homeassistant/*
sudo docker rm "home-assistant"
sudo docker pull homeassistant/home-assistant:latest
docker run -d --restart on-failure --name="home-assistant" -v /home/bnp/homeassistant:/config -v /etc/localtime:/etc/localtime:ro -v /run/dbus:/run/dbus:ro --net=host homeassistant/home-assistant


if HA wont start or the container keeps restarting:

docker logs --tail 50 --follow --timestamps "home-assistant"

or run the container in the foreground:

docker run -ti "home-assistant"


sudo docker stop "home-assistant"
sudo docker rm "home-assistant"
tar -xvf homeassistant.tar
sudo docker images

Remove the newest image (tagged as latest)

sudo docker rmi 66b09e12c04f

List images again

sudo docker images

Start on newest image Id (as it will have no tags)

sudo docker run -d --restart on-failure --name="home-assistant" -v /home/bnp/homeassistant:/config -v /etc/localtime:/etc/localtime:ro --net=host 93627847dd60

Broken Database

I got this in the logs

csqlite3.DatabaseError: database disk image is malformed

2020-06-06T14:53:15.012416986Z sqlalchemy.exc.InvalidRequestError: This Session's transaction has been rolled back due to a previous exception during flush. To begin a new transaction with this Session, first issue Session.rollback(). Original exception was: (sqlite3.DatabaseError) database disk image is malformed
2020-06-06T14:53:15.012430430Z [SQL: INSERT INTO events (event_type, event_data, origin, time_fired, created, context_id, context_user_id) VALUES (?, ?, ?, ?, ?, ?, ?)]
2020-06-06T14:53:15.012443081Z [parameters: ('state_changed', '{"entity_id": "sensor.hue_dimmer_switch_1_battery_level", "old_state": {"entity_id": "sensor.hue_dimmer_switch_1_battery_level", "state": "85", "attr ... (573 characters truncated) ... :00", "last_updated": "2020-06-06T14:53:14.119122+00:00", "context": {"id": "5ab6a95ba76548ea9d3833e194cce998", "parent_id": null, "user_id": null}}}', 'LOCAL', '2020-06-06 14:53:14.119249', '2020-06-06 14:53:14.138770', '5ab6a95ba76548ea9d3833e194cce998', None)]
2020-06-06T14:53:15.012461907Z (Background on this error at: (Background on this error at:

Fixed by this

docker stop "home-assistant"
apt-get install sqlite3
sqlite3 ./home-assistant_v2.db ".dump" | sqlite3 ./home-assistant_v2.db.fix
mv ./home-assistant_v2.db ./home-assistant_v2.db.broken
mv ./home-assistant_v2.db.fix ./home-assistant_v2.db
docker start "home-assistant"
docker logs --tail 50 --follow --timestamps "home-assistant"

No Errors in the logs


Start a MQTT Docker instance

docker run --init --restart on-failure --name mqtt --restart=always --net=host -p 1883:1883 -d ansi/mosquitto


Expand Home Assistant with Postgres in docker

Meet me at