# Mautic v5 Dockerization & Migration Guide - Prevent Internal Server Error & Failed Database Migration

**URL:** <https://forum.mautic.org/t/mautic-v5-dockerization-migration-guide-prevent-internal-server-error-failed-database-migration/34953>\
**Category:** Docker support\
**Created:** [February 6, 2025, 2:00pm UTC](https://forum.mautic.org/t/mautic-v5-dockerization-migration-guide-prevent-internal-server-error-failed-database-migration/34953 "2025-02-06T14:00:16Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![aymen](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/aymen/32/13647_2.png) [@aymen](https://forum.mautic.org/u/aymen)\
**Post date:** [February 6, 2025, 2:00pm UTC](https://forum.mautic.org/t/mautic-v5-dockerization-migration-guide-prevent-internal-server-error-failed-database-migration/34953/1 "2025-02-06T14:00:16Z")

</div>

![](https://us1.discourse-cdn.com/flex020/uploads/mautic/original/2X/c/c87b38eddcf879ac1bf5570ff41815eb15e3a9a7.png)

## Overview

This document outlines the step-by-step process to export the database from the live Mautic instance, set up a Dockerized version of Mautic, and migrate the database for testing and future deployment.

## Objectives

- Export the database from the live Mautic instance.
- Set up a Dockerized Mautic environment locally.
- Import the exported database into the new Dockerized instance.
- Test and validate the migration.

* * *

## 1. Export Database from Live Instance

1. **Dump the Database and transfer it to Local Machine:**
  - Run the following command to export the database:

```bash
mysqldump -u <DB_USER> -p'<DB_PASSWORD>' --host=<DB_HOST> <DB_NAME> > mautic_backup.sql

```

2. **Export the necessary media files**

* * *

## 2. Set Up Dockerized Mautic

### Steps:

1. **Clone Mautic Docker Repository:**

2. **Modify `docker-compose.yml`:**

3. **Start the Docker Containers:**

4. **Check Running Containers:**

* * *

## 3. Import Database into Dockerized Mautic

### Steps:

1. **Copy the Database and Access the Mautic Database Container:**

2. **Mautic 5 uses Symfony and Doctrine updates, which may have changed the way JSON fields are handled. If Mautic previously used json\_array and the new version expects json, this fix ensures compatibility.**

3. **Import the Backup:**

4. **Import media files:**

```bash
docker cp /path/to/local/files <MAUTIC_DB_CONTAINER>:/var/www/html/docroot/media/files
docker cp /path/to/local/images <MAUTIC_DB_CONTAINER>:/var/www/html/docroot/media/images

```

* * *

## 5. Running migration

1. **Run the migration command and !! check the logs**

```auto
docker compose exec <MAUTIC_WEB_CONTAINER> php ../bin/console doctrine:migrations:migrate --no-interaction --dry-run

```

1. **clear the cache**

```auto
docker compose exec <MAUTIC_WEB_CONTAINER> php ../bin/console cache:clear

```

* * *

## 4. Testing & Validation

### Steps:

1. **Verify Database Integrity:**

2. **Check Logs:**

3. **Access Mautic in the Browser:**

* * *

## 5. Notes

- Set proper permission \< MAUTIC\_WEB\_CONTAINER \>

```auto
chown -R www-data:www-data /var/www/html/
find /var/www/html/ -type d -exec chmod 755 {} \;
find /var/www/html/ -type f -exec chmod 644 {} \;

```

- Ensure all integrations and configurations are restored.
- for more docker setup examples check [https://github.com/mautic/docker-mautic/tree/mautic5](https://github.com/mautic/docker-mautic/tree/mautic5)
- Feel free to reach out!

---

<div class="post-metadata">

**Author:** ![zendev](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/zendev/32/13262_2.png) [@zendev](https://forum.mautic.org/u/zendev)\
**Post date:** [January 31, 2026, 8:33am UTC](https://forum.mautic.org/t/mautic-v5-dockerization-migration-guide-prevent-internal-server-error-failed-database-migration/34953/2 "2026-01-31T08:33:43Z")

</div>

I was able to migrate a baremetal Mautic 6 to Dockerized Mautic 6 with this guide, thanks!

A minor issue was that my config/local.php settings file, which I tried to copy at first, contained extensive configuration settings, including paths that didn’t seem to work out of the box in the new docker container. I had to more or less re-configure the new system with that as a guide.

I also updated the console binary path according to the Mautic 6.x docker config:

Migrate:

`docker compose exec mautic_web php /var/www/html/bin/console doctrine:migrations:migrate`

Check status:

`docker compose exec mautic_web php /var/www/html/bin/console doctrine:migrations:status`

Clear Cache:

`docker compose exec mautic_web php /var/www/html/bin/console cache:clear`
