services.server Additional property db is not allowed

问题

今天使用rocky-linux8.5安装了docker-composer然后安装了gitea,安装时遇到错误services.server Additional property db is not allowed

解决方法

首先是yml格式问题报了其他错误,解决之后就报上面错误,网上有人说是跟docker-compose的版本有关系,其实不是,我用的docker版本是20.10.12,docker-compose的版本是v2.2.2(离线安装),最后检查yml格式,其中镜像gitea和mysql不在同一层,mysql作为了gitea的子层了,gitea是depend-on mysql的,后面调整为同一级别就可以了

version: "3"

networks:
  gitea:
    external: false

services:
  server:
    image: gitea/gitea:1.15.7
    container_name: gitea
    environment:
      - USER_UID=1000
      - USER_GID=1000
      - DB_TYPE=mysql
      - DB_HOST=db:3306
      - DB_NAME=gitea
      - DB_USER=gitea
      - DB_PASSWD=gitea
    restart: always
    networks:
      - gitea
    volumes:
      - ./gitea:/data
      - /etc/timezone:/etc/timezone:ro
      - /etc/localtime:/etc/localtime:ro
    ports:
       - "3000:3000"
       - "222:22"
    depends_on:
       - db
 
  db:
    image: mysql:8
    restart: always
    environment:
      - MYSQL_ROOT_PASSWORD=gitea
      - MYSQL_USER=gitea
      - MYSQL_PASSWORD=gitea
      - MYSQL_DATABASE=gitea
    networks:
      - gitea
    volumes:
         - ./mysql:/var/lib/mysql

报错原因是depends_on是db,db与server不在同一层次上,用在线yml或者文本编辑器对比就找到原因了

上一篇:pycharm 安装插件


下一篇:对路径“……\……\……”的访问被拒绝