✨ Strapi MCP is now Generally Available - let your agents manage your Strapi content ✨

How tos3 min read

How to Self-Host your Headless CMS using Docker-Compose

May 25, 2021Updated on May 22, 2026

Strapi is a self-hosted Headless CMS. It means that you can run and maintain it on your own private servers. Several solutions are available for you to get started. You can use the CLI, one of our one click buttons or use Docker compose.

The last solution will allow you to create your self-hosted strapi project with any database and will be compatible on any OS.

What is Docker compose

Docker Compose is a command-line tool that uses a specially formatted descriptor file to take multiple docker containers and assemble them into applications which can then be run on a single host.

Our VP Marketing Victor Coisne wrote a full article about it: What is Docker Compose? All you need to know!

Get started with Docker compose

  • Create a docker-compose.yaml file in an empty folder. This docker-compose.yaml file will define your database, your Strapi service and links them. This will create a fresh new Strapi application where the docker-compose.yaml file is located.

However you may want to use a specific database. Find below all the possibilities:

SQLite

This will just create a simple Strapi project using an SQLite database.

version: '3'
services:
  strapi:
    image: strapi/strapi
    volumes:
      - ./app:/srv/app
    ports:
      - '1337:1337'

PostgreSQL

This will create a postgresql database, a Strapi project and link it to the database.

version: '3'
services:
  strapi:
    image: strapi/strapi
    environment:
      DATABASE_CLIENT: postgres
      DATABASE_NAME: strapi
      DATABASE_HOST: postgres
      DATABASE_PORT: 5432
      DATABASE_USERNAME: strapi
      DATABASE_PASSWORD: strapi
    volumes:
      - ./app:/srv/app
    ports:
      - '1337:1337'
    depends_on:
      - postgres

  postgres:
    image: postgres
    environment:
      POSTGRES_DB: strapi
      POSTGRES_USER: strapi
      POSTGRES_PASSWORD: strapi
    volumes:
      - ./data:/var/lib/postgresql/data

MongoDB

This will create a Mongodb database, a Strapi project and link it to the database.

version: '3'
services:
  strapi:
    image: strapi/strapi
    environment:
      DATABASE_CLIENT: mongo
      DATABASE_NAME: strapi
      DATABASE_HOST: mongo
      DATABASE_PORT: 27017
      DATABASE_USERNAME: strapi
      DATABASE_PASSWORD: strapi
    volumes:
      - ./app:/srv/app
    ports:
      - '1337:1337'
    depends_on:
      - mongo

  mongo:
    image: mongo
    environment:
      MONGO_INITDB_DATABASE: strapi
      MONGO_INITDB_ROOT_USERNAME: strapi
      MONGO_INITDB_ROOT_PASSWORD: strapi
    volumes:
      - ./data:/data/db

MySQL

This will create a MySQL database, a Strapi project and link it to the database.

version: '3'
services:
  strapi:
    image: strapi/strapi
    environment:
      DATABASE_CLIENT: mysql
      DATABASE_HOST: mysql
      DATABASE_PORT: 3306
      DATABASE_NAME: strapi
      DATABASE_USERNAME: strapi
      DATABASE_PASSWORD: strapi
      DATABASE_SSL: 'false'
    volumes:
      - ./app:/srv/app
    ports:
      - '1337:1337'
    depends_on:
      - mysql

  mysql:
    image: mysql
    command: mysqld --default-authentication-plugin=mysql_native_password
    volumes:
      - ./data:/var/lib/mysql
    environment:
      MYSQL_ROOT_PASSWORD: strapi
      MYSQL_DATABASE: strapi
      MYSQL_USER: strapi
      MYSQL_PASSWORD: strapi

MariaDB

This will create a MariaDB database, a Strapi project and link it to the database.

version: '3'
services:
  strapi:
    image: strapi/strapi
    environment:
      DATABASE_CLIENT: mysql
      DATABASE_HOST: mariadb
      DATABASE_PORT: 3306
      DATABASE_NAME: strapi
      DATABASE_USERNAME: strapi
      DATABASE_PASSWORD: strapi
      DATABASE_SSL: 'false'
    volumes:
      - ./app:/srv/app
    ports:
      - '1337:1337'
    depends_on:
      - mariadb

  mariadb:
    image: mariadb
    volumes:
      - ./data:/var/lib/mysql
    environment:
      MYSQL_ROOT_PASSWORD: strapi
      MYSQL_DATABASE: strapi
      MYSQL_USER: strapi
      MYSQL_PASSWORD: strapi

Start your containers

You are now ready to start a Strapi project using Docker compose! First you want to pull the latest images.

  • Pull the latest image by running the following command in your terminal:
docker-compose pull

By default, running the docker-compose up command for the first time automatically pull the images so this command is quite optionnal. This shoud take a moment, you'll be able to get a coffee ;)

  • Run your stack by running the following command:
docker-compose up # Executes Docker images without detaching the terminal
# or
docker-compose up -d # Executes Docker images detaching the terminal:

You database should have been created and your Strapi project must be installing dependencies, building and then start!

GIF

Please note: Since we initially published this blog post, we released new versions of Strapi and tutorials may be outdated. Sorry for the inconvenience if it's the case. Please help us by reporting it here.

Maxime CastresGrowth Engineer

Maxime started to code in 2015 and quickly joined the Growth team of Strapi. He particularly likes to create useful content for the awesome Strapi community. Send him a meme on Twitter to make his day: @MaxCastres

How tos·12 min read

How To Build A Static Blog Using Jekyll And Strapi

Static sites deliver fast performance but present a content management challenge: how do you let writers update blog...

·August 3, 2025
Build a Blog with Astro, Strapi, and Tailwind CSS
How tos·22 min read

How to Build a Blog with Astro, Strapi, and Tailwind CSS

This article has been updated to use Astro 4 and Strapi 5 by Juliet Ofoegbu.

·October 20, 2023
Build a CRUD App with Flutter and Strapi
How tos·12 min read

How to Build a Simple CRUD Application Using Flutter & Strapi

This article has been updated to use Strapi 5 and REST API by Ekekenta Odionyefe.

·August 23, 2023