Error installing in docker

Trying to install Home Assistant via Docker Compose, but I get this Error.

ERROR: The Compose file './docker-compose.yaml' is invalid because:
'homeassistant' does not match any of the regexes: '^x-'

You might be seeing this error because you're using the wrong Compose file version. Either specify a supported version (e.g "2.2" or "3.3") and place your service definitions under the `services` key, or omit the `version` key and place your service definitions at the root of the file to use version 1.

This is what I have in my docker-compose.yaml

version: '3.0'
services:
homeassistant:
    container_name: homeassistant
    image: "ghcr.io/home-assistant/home-assistant:stable"
    volumes:
      - /opt/homeassistant/config:/config
      - /etc/localtime:/etc/localtime:ro
    restart: unless-stopped

Error appears when I run

docker-compose up -d

I think your version should be 3.3. Indentation also looks off. This should work

version: '3.3'
services:
    home-assistant:
        container_name: homeassistant
        volumes:
            - '/opt/homeassistant/config:/config'
        environment:
            - TZ=America/New_York
        restart: unless-stopped
        network_mode: host
        image: 'ghcr.io/home-assistant/home-assistant:stable'

Replace with your time zone from this list

Thx 4 reply

Same error with your suggestion.

I followed this Linux - Home Assistant

Must be something I’m missing. Installed portainer the same way without any problems

My bad

Had a wrong indention in one line.

I had the same error and it took me a while to realise I had to indent the word homeassistant one step and it all worked