docker-compose错误无效类型,它应该是一个字符串

vin*_*ran 15 docker docker-compose gitlab-omnibus gitlab-ce

我有这样的 docker-compose 设置

version: "3.2"

services:
   gitlab:
       image: gitlab/gitlab-ce:latest
       container_name: gitlab-container
       restart: always
       environment:
           - GITLAB_OMNIBUS_CONFIG: |
                   external_url 'https://192.46.223.235'
                   gitlab_rails['gitlab_shell_ssh_port'] = 10022
                   letsencrypt['enabled'] = false
                   nginx['enable'] = true
                   nginx['redirect_http_to_https'] = false
                   nginx[listen_port] = 10080
                   nginx[listen_https] = false
       ports:
           - "10080:80"
           - "10022:22"

       volumes:
           - '$GITLAB_HOME/config:/etc/gitlab'
           - '$GITLAB_HOME/logs:/var/log/gitlab'
           - '$GITLAB_HOME/data:/var/opt/gitlab'
Run Code Online (Sandbox Code Playgroud)

因此,当我运行 docker-compose up -d 时,出现以下错误:

WARNING: The GITLAB_HOME variable is not set. Defaulting to a blank string.
ERROR: The Compose file './docker-compose.yml' is invalid because:
services.gitlab.environment contains {"GITLAB_OMNIBUS_CONFIG": "-  external_url 'https://192.46.223.235'\n-  gitlab_rails['gitlab_shell_ssh_port'] = 10022\n  letsencrypt['enabled'] = false\n  nginx['enable'] = true\n  nginx['redirect_http_to_https'] = false\n  nginx[listen_port] = 10080\n  nginx[listen_https] = false\n"}, which is an invalid type, it should be a string
Run Code Online (Sandbox Code Playgroud)

请帮助!

Dav*_*aze 27

删除-之前的GITLAB_OMNIBUS_CONFIG.

Composeenvironment:块支持两种语法:

version: '3.8'
services:
  environment_as_list:
    environment:
      - KEY=value
      - LINES=start with minus
      - COLONS=false
  environment_as_map:
    environment:
      KEY: value
      LINES: do not start with minus
      COLONS: 'true'
Run Code Online (Sandbox Code Playgroud)

您拥有的语法以 a 开头-,因此它是一个 YAML 列表,但它有key: value语法,因此列表项是一个 YAML 映射。使用块标量语法,您需要映射形式,因此删除前导-(并修复缩进)以使其不是列表。