Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bootstrap Strapi with docker-compose

I am getting the following error and cannot figure out, what's wrong:

I have read the documentation carefully, and made a docker-compose.yml based on an example found at https://github.com/strapi/strapi-docker/blob/master/examples/mysql/docker-compose.yml

api_1       | Using strapi 3.0.0-beta.19.3
api_1       | No project found at /srv/app. Creating a new strapi project
api_1       | Creating a new Strapi application at /srv/app.
api_1       |
api_1       | ⛔️ You can only create a Strapi app in an empty directory.
api_1       | Make sure /srv/app is empty.

That is my docker-compose.yml

version: "2.4"

services:
  api:
    depends_on:
      - database

    image: strapi/strapi

    container_name: core_api

    environment:
      #APP_NAME: wlc-core
      DATABASE_CLIENT: mysql
      DATABASE_HOST: database
      DATABASE_PORT: 3306
      DATABASE_NAME: development
      DATABASE_USERNAME: development
      DATABASE_PASSWORD: development
      DATABASE_SSL: "false"

    ports:
      - 1337:1337

    volumes:
      - ./services/api/api:/srv/app/api
      - ./services/api/config:/srv/app/config
      - ./services/api/extensions:/srv/app/extensions
      - ./services/api/public:/srv/app/public

  database:
    image: mariadb:10.4.4-bionic

    container_name: core_database

    volumes:
      - ./services/database/data:/var/lib/mysql

    ports:
      - 3306:3306

    environment:
      MYSQL_ROOT_PASSWORD: development
      MYSQL_DATABASE: development
      MYSQL_USER: development
      MYSQL_PASSWORD: development

I got that container running once. But since then it cannot be run anymore. I removed the stopped container, that was created before building a new one.

like image 983
Edgar Alloro Avatar asked Feb 04 '26 07:02

Edgar Alloro


1 Answers

You are configuring the wrong volumes. As stated in the Github link you provided, the only volume you need to mount in core_api is the following:

volumes:
    - ./app:/srv/app

Or in your case:

volumes:
    - ./services/api:/srv/api

The app directory contains the whole application (APIs, models, configurations, etc...). so you don't need to mount every subdirectory, only the top-level one.

like image 80
Convly Avatar answered Feb 12 '26 16:02

Convly



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!