简体   繁体   中英

How do I fix my docker-compose.yml? - Unsupported config option for services.teslamate: 'database'

I am new to this today. I have been trying to figure out what the problem is all day.

docker-compose version 1.28.5, build 324b023a

I run: docker-compose up -d

and I get: ERROR: The Compose file './docker-compose.yml' is invalid because: Unsupported config option for services.teslamate: 'database'

version: "3"

services:
  teslamate:
    image: teslamate/teslamate
    restart: always
    environment:
      - ENCRYPTION_KEY= <Insert Key>
      - DB_USER=teslamate
      - DB_PASS= <Insert password>
      - DB_NAME=teslamate
      - DB_HOST=database
      - MQTT_HOST=mosquitto
      - VIRTUAL_HOST=<Insert IP address>
        # if you're going to access the UI from another machine replace
        # "localhost" with the hostname / IP address of the docker host.
      - TZ=US # (optional) replace to use local time in debug logs. See    "Configuration".
    ports:
      - 4000:4000
    volumes:
      - ./import:/opt/app/import
    cap_drop:
      - all

    database:
    image: postgres:14
    restart: always
    environment:
      - POSTGRES_USER=teslamate
      - POSTGRES_PASSWORD= <Insert password>
      - POSTGRES_DB=teslamate
    volumes:
      - teslamate-db:/var/lib/postgresql/data

    grafana:
    image: teslamate/grafana
    restart: always
    environment:
      - DATABASE_USER=teslamate
      - DATABASE_PASS= goforit
      - DATABASE_NAME=teslamate
      - DATABASE_HOST=database
    ports:
      - 3000:3000
    volumes:
      - teslamate-grafana-data:/var/lib/grafana

    mosquitto:
    image: eclipse-mosquitto:2
    restart: always
    command: mosquitto -c /mosquitto-no-auth.conf
    # ports:
    #   - 1883:1883
    volumes:
      - mosquitto-conf:/mosquitto/config
      - mosquitto-data:/mosquitto/data

volumes:
  teslamate-db:
  teslamate-grafana-data:
  mosquitto-conf:
  mosquitto-data:

Could someone please let me know what is wrong? Thank you,

It is just a Yaml indentation problem. Your services teslamate, database, grafana and mosquito needs to have the same indentation, otherwise database is seen as a property of teslamate and it is not a valid property for docker-compose.

version: "3"

services:
  teslamate:
    image: teslamate/teslamate
    restart: always
    environment:
      - ENCRYPTION_KEY= <Insert Key>
      - DB_USER=teslamate
      - DB_PASS= <Insert password>
      - DB_NAME=teslamate
      - DB_HOST=database
      - MQTT_HOST=mosquitto
      - VIRTUAL_HOST=<Insert IP address>
        # if you're going to access the UI from another machine replace
        # "localhost" with the hostname / IP address of the docker host.
      - TZ=US # (optional) replace to use local time in debug logs. See    "Configuration".
    ports:
      - 4000:4000
    volumes:
      - ./import:/opt/app/import
    cap_drop:
      - all

  database:
    image: postgres:14
    restart: always
    environment:
      - POSTGRES_USER=teslamate
      - POSTGRES_PASSWORD= <Insert password>
      - POSTGRES_DB=teslamate
    volumes:
      - teslamate-db:/var/lib/postgresql/data

  grafana:
    image: teslamate/grafana
    restart: always
    environment:
      - DATABASE_USER=teslamate
      - DATABASE_PASS= goforit
      - DATABASE_NAME=teslamate
      - DATABASE_HOST=database
    ports:
      - 3000:3000
    volumes:
      - teslamate-grafana-data:/var/lib/grafana

  mosquitto:
    image: eclipse-mosquitto:2
    restart: always
    command: mosquitto -c /mosquitto-no-auth.conf
    # ports:
    #   - 1883:1883
    volumes:
      - mosquitto-conf:/mosquitto/config
      - mosquitto-data:/mosquitto/data

volumes:
  teslamate-db:
  teslamate-grafana-data:
  mosquitto-conf:
  mosquitto-data:

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM