0

I found this docker compose container on an asian site, and was trying to run it, and then I got the following. I had to modify the docker compose file because there were duplicated characters. I'm not sure why this won't run, and i have looked on stackoverflow for other issues, but none resolved my issue.

The docker compose file is as follows:

---
version: '3.5'
services:
    wowonder-web:
        container_name: wowonder-web
        image: webdevops/php-apache:debian-10
        environment:
            -WEB_DOCUMENT_ROOT=/app
            -PHP_MEMORY_LIMIT=1024M
            -PHP_MAX_EXECUTION_TIME=7200
            -PHP_POST_MAX_SIZE=10240M
            -PHP_UPLOAD_MAX_FILESIZE=10240M
            -FPM_MAX_REQUESTS=500
            -FPM_PM_MAX_CHILDREN=20
            -FPM_PM_START_SERVERS=10
            -FPM_PM_MIN_SPARE_SERVERS=5
            -FPM_PM_MAX_SPARE_SERVERS=15
        
        volumes: 
            - /opt/wowonder/app:/appwowonder:/app
        restart: unless-stopped

    wowonder-db:
        container_name: wowonder-db
        image: mariadb
        environment: 
            -MYSQL_ROOT_PASSWORD="wowonder"
            -MYSQL_PASSWORD="wowonder"
            -MYSQL_DATABASE="wowonder"
            -MYSQL_USER="wowonder"
        volumes: 
            - /docker/Databases/wowonder:/var/lib/mysqldb
            command: --sql-mode="NO_ENGINE_SUBSTITUTION"  
        restart: unless-stopped 

networks:
    default:
        external:
            name: imlala
David Maze
  • 130,717
  • 29
  • 175
  • 215

1 Answers1

0

A few mistypes (check this online YAML validator in the future):

First, as @DavidMaze noted, to create a YAML array in a docker-compose file the most popular option is to create a new line for each element and start with a hyphen and a space right after it, you can browse other options in this SO thread

        environment:
            - WEB_DOCUMENT_ROOT=/app
            - PHP_MEMORY_LIMIT=1024M
            - PHP_MAX_EXECUTION_TIME=7200
            - PHP_POST_MAX_SIZE=10240M
            - PHP_UPLOAD_MAX_FILESIZE=10240M
            - FPM_MAX_REQUESTS=500
            - FPM_PM_MAX_CHILDREN=20
            - FPM_PM_START_SERVERS=10
            - FPM_PM_MIN_SPARE_SERVERS=5
            - FPM_PM_MAX_SPARE_SERVERS=15

Second, your command for wowonder-db was too much indented, taking it a step back fixed the issue.

        volumes: 
            - /docker/Databases/wowonder:/var/lib/mysqldb
        command: --sql-mode="NO_ENGINE_SUBSTITUTION"  
        restart: unless-stopped 

Complete and valid compose file:

---
version: '3.5'
services:
    wowonder-web:
        container_name: wowonder-web
        image: webdevops/php-apache:debian-10
        environment:
            - WEB_DOCUMENT_ROOT=/app
            - PHP_MEMORY_LIMIT=1024M
            - PHP_MAX_EXECUTION_TIME=7200
            - PHP_POST_MAX_SIZE=10240M
            - PHP_UPLOAD_MAX_FILESIZE=10240M
            - FPM_MAX_REQUESTS=500
            - FPM_PM_MAX_CHILDREN=20
            - FPM_PM_START_SERVERS=10
            - FPM_PM_MIN_SPARE_SERVERS=5
            - FPM_PM_MAX_SPARE_SERVERS=15
        
        volumes: 
            - /opt/wowonder/app:/appwowonder:/app
        restart: unless-stopped

    wowonder-db:
        container_name: wowonder-db
        image: mariadb
        environment: 
            - MYSQL_ROOT_PASSWORD="wowonder"
            - MYSQL_PASSWORD="wowonder"
            - MYSQL_DATABASE="wowonder"
            - MYSQL_USER="wowonder"
        volumes: 
            - /docker/Databases/wowonder:/var/lib/mysqldb
        command: --sql-mode="NO_ENGINE_SUBSTITUTION"  
        restart: unless-stopped 

networks:
    default:
        external:
            name: imlala
Noam Yizraeli
  • 4,446
  • 18
  • 35
  • 1
    Hey I used your docker compose file and it ran until, i got the following message. Cannot create container for service wowonder-web: invalid mode: /app app refers to the web document root – Orange Training Sep 25 '21 at 12:01
  • 1
    ok so i found out it was the volume mapping was wrong. I changed it and now it works, and i added ports to the dockerfile but it won't publish any ports – Orange Training Sep 25 '21 at 12:10
  • you need to add ports section to your compose file, see [this](https://docs.docker.com/compose/compose-file/compose-file-v3/#ports) example – Noam Yizraeli Sep 25 '21 at 12:12
  • I fixed the issue. Thanks – Orange Training Sep 25 '21 at 12:43
  • by adding the `ports` section? If so I'm glad . please accept the answer if it helped you solve your issue with the check mark – Noam Yizraeli Sep 25 '21 at 12:46
  • I tried to use this docker compose file and it actually worked. When i try to use wonder-db as host/wowonder as user and wowonder as password it says it cannot connect to the database!!! – Orange Training Sep 27 '21 at 23:27
  • wait, so did it work or not? and if not, what error are you getting? – Noam Yizraeli Sep 28 '21 at 08:34