Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

docker-compose error invalid type, it should be a string

I have the set-up for docker-compose like this

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'

So, when I run docker-compose up -d, I got the following error :

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

Help, please!

like image 317
vinh tran Avatar asked Dec 02 '25 16:12

vinh tran


2 Answers

Remove the - before GITLAB_OMNIBUS_CONFIG.

The Compose environment: block supports two syntaxes:

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'

The syntax you have starts with a -, so it's a YAML list, but then it has key: value syntax, so the list item is a YAML mapping. With the block-scalar syntax you need the mapping form, so remove the leading - (and fix the indentation) to make it not be a list.

like image 122
David Maze Avatar answered Dec 04 '25 07:12

David Maze


I got this error and it turned out that I typed docker-compose instead of the newer docker compose (without the -).

like image 21
Daniel Veihelmann Avatar answered Dec 04 '25 06:12

Daniel Veihelmann



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!