Question

[Solved] yml docker-compose error mapping values are not allowed here

I try to learn about container, but i have a problem with my docker-compose.yml file, after i run the docker compose up, i always get the same error:

“ERROR: yaml.scanner.ScannerError: mapping values are not allowed
here”

even if i changed the mount path to docker volume, i got the same error, this is my yml file

version: "3"

services:
    database:
        image: mariadb
        ports: 
            - "3260:3260"
        volumes:
            - /home/randy/Desktop/Latihan/wordpress-mariadb/mariadb:var/lib/mysql
         environment:
            MYSQL_ROOT_PASSWORD: root

    wordpress:
        image: wordpress
        ports:
            - "2000:80"
        volumes:
            - /home/randy/Desktop/Latihan/wordpress-mariadb/wordpress:/var/www/html
        environment:
            WORDPRESS_DB_PASSWORD: root
        depends_on:
            - database
        links:
            - database

Solution #1:

It appears that your yaml is invalid. When I face these types of issues, what I will do is use a site called http://www.yamllint.com/ which will validate the syntax for you.

This yaml based on your example is valid:

Note: You can use 4 spaces (or 2 which I prefer), but never use tabs.

version: "3"

services: 
  database: 
    environment: 
      MYSQL_ROOT_PASSWORD: root
    image: mariadb
    ports: 
      - "3260:3260"
    volumes: 
      - "/home/randy/Desktop/Latihan/wordpress-mariadb/mariadb:var/lib/mysql"
  wordpress:
    image: wordpress
    ports:
      - "2000:80"
    volumes:
      - /home/randy/Desktop/Latihan/wordpress-mariadb/wordpress:/var/www/html
    environment:
      WORDPRESS_DB_PASSWORD: root
    depends_on:
      - database
    links:
      - database
Respondent: leeman24

The answers/resolutions are collected from stackoverflow, are licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0 .

Most Popular

To Top
India and Pakistan’s steroid-soaked rhetoric over Kashmir will come back to haunt them both clenbuterol australia bossier man pleads guilty for leadership role in anabolic steriod distribution conspiracy