Yml Docker-Compose Error Mapping Values Are Not Allowed Here

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
4

1 Answer

It appears that your yaml is invalid. When I face these types of issues, what I will do is use a site called 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
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Chloe Bennett
Author

Chloe Bennett

Chloe Bennett explores the intersection of pop culture, streaming entertainment, digital trends, and contemporary lifestyle. Her weekly commentary reaches thousands of culture enthusiasts.