Docker Community Forums

Share and learn in the Docker community.

Docker compose multi services

hi, i want to run 2 applications in my docker compose but i don’t succeed.
my two applications are wordpress and nextcloud.

you can see my docker-compose.yml:

version: '3'
services:
  db:
    image: mariadb
    volumes:
      - db_data:/var/lib/mysql
    restart: always
    environment:
      MYSQL_ROOT_PASSWORD: somewordpress
      MYSQL_DATABASE: wordpress
      MYSQL_USER: wordpress
      MYSQL_PASSWORD: wordpress

  db2:
     image: mariadb
     volumes:
       - db2_data: /var/lib/mysql/nextcloud
     restart: always
     environment:
      MYSQL_ROOT_PASSWORD: password      
      MYSQL_DATABASE: nextcloud
      MYSQL_USER: nextcloud
      MYSQl_PASSWORD: nextcloud
    
  wordpress:
    depends_on:
      - db
    image: wordpress:latest
    ports:
      - "8000:80"
    restart: always
    environment:
      WORDPRESS_DB_HOST: db:3306
      WORDPRESS_DB_USER: wordpress
      WORDPRESS_DB_PASSWORD: wordpress
      WORDPRESS_DB_NAME: wordpress

 nextcloud:
    depends_on:
      - db2
     image: nextcloud:latest
     ports:
       - "2368:85"
     restart: always
     environment:
        NEXTCLOUD_DB_HOST: db:3306
        NEXTCLOUD_DB_USER: nextcloud
        NEXTCLOUD_DB_PASSWORD: nextcloud
        NEXTCLOUD_DB_NAME: nextcloud

volumes:
  db_data: {}

but i am not sure to my docker-compose.
and i have these errors:
Capture

thank’s for your answer

Line 38:

There is a space missing. You need to have two spaces for indent.

after fixed it these errors i a have new errors:
Capture
I don’t understand what are the errors

thank’s for your answers

The indentation between line 41 and 49 is wrong. Remove 1 space so they align with ‘depends_on’. Then the indentation under ‘environment’ should be plus 2, not plus 3 spaces. I recommend that you use an editor where you see these things, like Vim or VS Code.

il fixed à lot of problems but i am news problems/


i don’t know what to do

do you have any solutions ?

You are aware that yaml uses indention levels to group items, aren’t you?
A valid indention always consists of two space characters.

Emtpy lines must be realy empty and do not contain any whitespace character.