> ## Documentation Index
> Fetch the complete documentation index at: https://docs.mastermindcms.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Run with Docker

> Start MastermindCMS with Docker / Docker Compose

## Prerequisites

You need:

* Docker
* Docker Compose (v2)

## Start the stack

1. Set the MastermindCMS version in your `.env`:

```dotenv theme={null}
TAG="2.16.8"
```

2. Start containers:

```shell theme={null}
docker compose --env-file .env up -d
```

3. Open MastermindCMS in your browser:

`http://localhost:5000`

## Mounted folders

Docker Compose mounts these folders into the container (so you edit locally, CMS reads inside the container):

* `./www  -> /MSM2/www`
* `./files -> /MSM2/files`
* `./config -> /MSM2/config`

## Example `docker-compose.yml`

```yaml theme={null}
version: "${TAG}"
services:
  mongodb-msm2-demo:
    image: mongo:4.4
    command: mongod --port ${DB_PORT}
    container_name: mongodb-msm2-demo
    restart: always
    healthcheck:
      test: echo 'db.adminCommand('ping').ok' | mongo admin -u ${MONGO_INITDB_ROOT_USERNAME} -p ${MONGO_INITDB_ROOT_PASSWORD} --quiet | grep 1
      interval: 30s
      timeout: 10s
      retries: 5
    volumes:
      - ${WORKING_DIR}/data:/data/db
    ports:
      - ${DB_PORT}:${DB_PORT}
    environment:
      - MONGO_INITDB_ROOT_USERNAME=${MONGO_INITDB_ROOT_USERNAME}
      - MONGO_INITDB_ROOT_PASSWORD=${MONGO_INITDB_ROOT_PASSWORD}
      - MONGO_INITDB_DATABASE=admin
  mastermindcms-demo:
    image: mastermindcms/enterprise:${TAG}
    container_name: mastermindcms-demo
    restart: always

    volumes:
      - ${WORKING_DIR}/www:/MSM2/www
      - ${WORKING_DIR}/files:/MSM2/files
      - ${WORKING_DIR}/config:/MSM2/config
    user: "1000:1000"
    ports:
      - 5000:5000
    environment:
      - SPRING_DATA_MONGODB_URI=mongodb://${MONGO_INITDB_ROOT_USERNAME}:${MONGO_INITDB_ROOT_PASSWORD}@mongodb-msm2-demo:${DB_PORT}/admin?authSource=admin
    depends_on:
      mongodb-msm2-demo:
        condition: service_healthy
```

## Environment variables (`.env`)

| Variable                     | What it controls                                                                   | Notes                                                                                                                                                       |
| ---------------------------- | ---------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `TAG`                        | MastermindCMS image tag used by Docker Compose (`mastermindcms/enterprise:${TAG}`) | Set this to the version you want to run, e.g. `2.16.8`.                                                                                                     |
| `DB_PORT`                    | MongoDB port                                                                       | The compose file maps this port on the host and uses it inside the MongoDB container. Change if the port is already in use.                                 |
| `MONGO_INITDB_ROOT_USERNAME` | MongoDB root username                                                              | Used to initialize the MongoDB instance on first start.                                                                                                     |
| `MONGO_INITDB_ROOT_PASSWORD` | MongoDB root password                                                              | Used to initialize the MongoDB instance on first start. Change it for anything beyond local demos.                                                          |
| `WORKING_DIR`                | Host folder used for mounted volumes                                               | Compose mounts `${WORKING_DIR}/www`, `${WORKING_DIR}/files`, `${WORKING_DIR}/config`, `${WORKING_DIR}/data`. Keep `.` to use the current compose directory. |
| `REPO_USER`                  | Repository username (package/download access)                                      | Used for installations that pull artifacts from a protected repository (not required for the basic Docker Compose demo).                                    |
| `REPO_PASS`                  | Repository password (package/download access)                                      | Same as above. Treat as a secret.                                                                                                                           |
| `LOCALE_ALL`                 | Locale (LC\_ALL)                                                                   | Optional. Useful when the runtime environment needs a specific locale (e.g. sorting, formatting).                                                           |
| `LOCALE_LANG`                | Locale (LANG)                                                                      | Optional.                                                                                                                                                   |
| `LOCALE_LANGUAGE`            | Locale language list (LANGUAGE)                                                    | Optional.                                                                                                                                                   |

<Note>
  The example `.env` often contains default credentials (like MongoDB root password). Change them for anything beyond local demos.
</Note>
