Docker Community Forums

Share and learn in the Docker community.

Help with yml, values do not match any regexes

This is now solved, it was an indentation issue, which I had thought I had figured out, but missed.

I hope this is the right place. I am very new to Docker, and am following this guide. I tried copy/pasting the yml directly from the site but ran into some indentation errors/problems. I think I have all those worked out, and am now encountering the errors below.

 # docker-compose --verbose -f config
compose.config.config.find: Using configuration files: ./
ERROR: compose.cli.main.main: The Compose file './' is invalid because:
networks.healthcheck value 'disable', 'restart' do not match any of the regexes: '^x-'
networks.dns_net value 'ipv4_address', 'ports', 'volumes' do not match any of the regexes: '^x-'

Here is the yml I am using:

version: '3'

    driver: bridge
    - subnet:

    container_name: pihole
    hostname: pihole
    image: pihole/pihole:latest
  - "53:53/tcp"
  - "53:53/udp"
  - "80:80/tcp"
  - "443:443/tcp"
  - 'TZ=Australia/Sydney'
  - 'WEBPASSWORD=yourpasswd'
  - 'DNS1='
  - 'DNS2=no'
  - '/home/pi/pihole/etc-pihole/:/etc/pihole/'
  - '/home/pi/pihole/etc-dnsmasq.d/:/etc/dnsmasq.d/'
  restart: unless-stopped

  container_name: unbound
  image: mvance/unbound:latest
     - /home/pi/unbound:/opt/unbound/etc/unbound
    - "5053:5053/tcp"
    - "5053:5053/udp"
    disable: true
    restart: unless-stopped

Can someone tell me what is wrong, or point me in a direction? This is on a ODROID-N2 running CoreELEC 9.2.5. I have ran this exact yml through a few different yml validators/checkers online, and it passes, and Google is no help with the two errors I am getting.

Your indentions are wrong. If you compare your compose.yml with the one from the tutorial, you should immediatly see whats wrong… Only the first 14 lines have correct indention.

Visual Studio Code has a nice plugin to support yaml editing: indent-rainbow
It will add different vertical colours for every two columns, which allows to niceley see how each line is indented.

Thank you, I thought I had the indentation right, but now I know I was wrong. I will go back, and try again. Thank you for the suggestion on Visual Studio Code, I might have to try it out, but for now I will stick with what I know Notepad++.

Is there a lint for compose.yml?

For example if one is creating JSON, then there is a lint for JSON, i.e. JSONLint

I know that docker-compose has a build in command to verify compose.yml. It is quite usefull if you work with extending a base config with additional configs, as it will render the final compose.yml to be applied during deployment.

[update] I missed that the first line of the first code block actualy leverages the validation. Even though it addresses the offending configuration items in a flattend representation, the lack of line numbers isn’t realy beginner friendly…[/update] looks promissing. Though, not sure if there actualy is a docker-compose specific linter that covers all file versions. In reality it should be easy to implement: extend one of the existing linters, create a validation schema (v3 schemas can be found as json schema here) and make the linter validate the yml against the schema.

1 Like

I had a few paragraphs written but then read further and noticed you noted config_schema_v3.0.json which I fully agree should be a check done in the pipeline before using a compose.yml. I don’t know if I would consider it a full semantic check but it is better than a basic yml syntax check. :slightly_smiling_face:

Glad to hear that!!

Thx a lot.

ร้านค้า บิทคอยน์ คริปโต

ariable substitution works for YAML’s array elements and hash values, but does not work for hash keys (see the last line):

version: “3”

image: ubuntu
- $VOL


VOL=some_vol docker-compose up ERROR: The Compose file './docker-compose.yml' is invalid because: volumes value '{VOL}’ does not match any of the regexes: u’^[a-zA-Z0-9._-]+$’
I’m running docker-compose version 1.17.1, build 6d101fb.

Thank you for the info.

nice post!!

Merchant Crypto