skip to Main Content

I am trying to create a docker-compose.yml file from 0 following this guide.

When I try to run the container I get the following error: yaml: line 29: could not find expected ':'

I’ve read everywhere and I find indentation problems, but I haven’t been able to tell why my file won’t run, any help would be Highly apreciated. My docker-compose.yml file contains the following:

version: "3.9"
########################### NETWORKS
# You may customize the network subnet (192.168.89.0/24) below as you please.
# Docker Compose version 3.5 or higher required to define networks this way.

networks:
  default:
    driver: bridge
  npm_proxy:
    name: npm_proxy
    driver: bridge
    ipam:
      config:
        - subnet: 192.168.89.0/24
########################### EXTENSION FIELDS
# Helps eliminate repetition of sections
# More Info on how to use this: https://github.com/htpcBeginner/docker-traefik/pull/228

# Common environment values
x-environment: &default-tz-puid-pgid
  TZ: $TZ
  PUID: $PUID
  PGID: $PGID

# Keys common to some of the core services that we always to automatically restart on failure
x-common-keys-core: &common-keys-core
  networks:
    - npm_proxy
  security_opt:
    - no-new-privileges:true
  restart: always

# Keys common to some of the dependent services/apps
x-common-keys-apps: &common-keys-apps
  networks:
    - npm_proxy
  security_opt:
    - no-new-privileges:true
  restart: unless-stopped

# Keys common to some of the services in media-services.txt
x-common-keys-media: &common-keys-media
  networks:
    - npm_proxy
  security_opt:
    - no-new-privileges:true
  restart: "no"

########################### SERVICES
services:
################ FRONTENDS
# Nginx Proxy Manager - Reverse Proxy with LetsEncrypt
  npm:
    <<: *common-keys-core # See EXTENSION FIELDS at the top
    container_name: nginx-proxy-manager
    image: 'jc21/nginx-proxy-manager:latest'
    # For Static IP
    networks:
    # For Static IP
      npm_proxy:
        ipv4_address: 192.168.89.254 # You can specify a static IP
    # For Dynamic IP
    # networks:
    #  - npm_proxy
    ports:
      - '80:80' # Public HTTP Port. Port Forwarding on Router is ON.
      - '443:443' # Public HTTPS Port. Port Forwarding on Router is ON.
      - '81:81' # Admin Web Port. Port Forwarding on Router is OFF. Internal Home Network Access only - 192.168.89.254:81.
    volumes:
      - $DOCKERDIR/appdata/npm/config:/config
      - $DOCKERDIR/appdata/npm/letsencrypt:/etc/letsencrypt
      - $DOCKERDIR/appdata/npm/data:/data
    environment:
      DB_SQLITE_FILE: "/config/database.sqlite"
      DISABLE_IPV6: 'true'

I’ve tried reviewing the indentation, and changing some environment variables definitions ex:
TZ: $TZ to - TZ=$TZ

2

Answers


  1. Chosen as BEST ANSWER

    Ok! So I found out what the problem was, since I was following the guide posted, it had code blocks where you can copy/paste parts of the docker-compose file.

    I was using nano to modify the file using SSH to connect to my home server, I was getting tired of using that so I pasted my code on VSCode and found out that some of the blank spaces where not spaces but U+00a0 characters, I simply used find and replace tool to change this characters into a space character and it worked!

    Thanks everyone for the quick replies


  2. On my VSCode, your code showed 29 errors.

    Here is a version with none, please try what happens:

    version: "3.9"
    ########################### NETWORKS
    # You may customize the network subnet (192.168.89.0/24) below as you please.
    # Docker Compose version 3.5 or higher required to define networks this way.
    
    networks:
      default:
       driver: bridge
      npm_proxy:
       name: npm_proxy
       driver: bridge
       ipam:
        config:
         - subnet: 192.168.89.0/24
    ########################### EXTENSION FIELDS
    # Helps eliminate repetition of sections
    # More Info on how to use this: https://github.com/htpcBeginner/docker-traefik/pull/228
    
    # Common environment values
    x-environment: &default-tz-puid-pgid
     TZ: $TZ
     PUID: $PUID
     PGID: $PGID
    
    # Keys common to some of the core services that we always to automatically restart on failure
    x-common-keys-core: &common-keys-core
     networks:
      - npm_proxy
     security_opt:
      - no-new-privileges:true
     restart: always
    
    # Keys common to some of the dependent services/apps
    x-common-keys-apps: &common-keys-apps
     networks:
      - npm_proxy
     security_opt:
      - no-new-privileges:true
     restart: unless-stopped
    
    # Keys common to some of the services in media-services.txt
    x-common-keys-media: &common-keys-media
     networks:
      - npm_proxy
     security_opt:
      - no-new-privileges:true
     restart: "no"
    
    ########################### SERVICES
    services:
    ################ FRONTENDS
    # Nginx Proxy Manager - Reverse Proxy with LetsEncrypt
      npm:
        <<: *common-keys-core # See EXTENSION FIELDS at the top
        container_name: nginx-proxy-manager
        image: 'jc21/nginx-proxy-manager:latest'
        # For Static IP
        networks:
        # For Static IP
          npm_proxy:
            ipv4_address: 192.168.89.254 # You can specify a static IP
        # For Dynamic IP
        # networks:
        #  - npm_proxy
        ports:
          - '80:80' # Public HTTP Port. Port Forwarding on Router is ON.
          - '443:443' # Public HTTPS Port. Port Forwarding on Router is ON.
          - '81:81' # Admin Web Port. Port Forwarding on Router is OFF. Internal Home Network Access only - 192.168.89.254:81.
        volumes:
          - $DOCKERDIR/appdata/npm/config:/config
          - $DOCKERDIR/appdata/npm/letsencrypt:/etc/letsencrypt
          - $DOCKERDIR/appdata/npm/data:/data
        environment:
          DB_SQLITE_FILE: "/config/database.sqlite"
          DISABLE_IPV6: 'true'
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search