Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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
like image 847
Randy Ramandani Avatar asked Jan 25 '23 20:01

Randy Ramandani


1 Answers

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
like image 126
leeman24 Avatar answered Jan 28 '23 09:01

leeman24