# Guide to upgrading from v4 to v5 on Docker?

**URL:** <https://forum.mautic.org/t/guide-to-upgrading-from-v4-to-v5-on-docker/30801>\
**Category:** Product Support\
**Tags:** mautic-4\
**Created:** [February 6, 2024, 10:18am UTC](https://forum.mautic.org/t/guide-to-upgrading-from-v4-to-v5-on-docker/30801 "2024-02-06T10:18:58Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![mchojrin](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/mchojrin/32/10159_2.png) [@mchojrin](https://forum.mautic.org/u/mchojrin)\
**Post date:** [February 6, 2024, 10:18am UTC](https://forum.mautic.org/t/guide-to-upgrading-from-v4-to-v5-on-docker/30801/1 "2024-02-06T10:18:59Z")

</div>

My Mautic version is: 4.1.11  
My PHP version is: 7.4.33  
My Database type and version is: 5.7.44

**Your problem**  
I have a docker installation based on mautic:v4. I want to upgrade it to v5 and I was wondering if there’s a guide on how to make this upgrade.

Thanks,

---

<div class="post-metadata">

**Author:** ![mchojrin](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/mchojrin/32/10159_2.png) [@mchojrin](https://forum.mautic.org/u/mchojrin)\
**Post date:** [February 20, 2024, 9:26am UTC](https://forum.mautic.org/t/guide-to-upgrading-from-v4-to-v5-on-docker/30801/2 "2024-02-20T09:26:18Z")

</div>

So I couldn’t find any step-by-step guide to performing this upgrade so I’m trying to figure it out on my own.

So far what I got is this:

The files that should survive the container life-cycle are those inside the directories:

- `media/files`
- `media/images`
- `media/dashboards`

Plus the file `app/config/local.php`.

**If you know of any other important user file please let me know** (I’m kind of new to Mautic).

So, my idea was to change my `docker-compose.yml` to reflect this situation instead of mounting the whole `/var/www/html` directory which will get overwritten by the new version anyway…

Next step: change the image from `mautic/mautic:v4` to `mautic/mautic:5.0.3-apache` and to `mysql:8.0` for the database.

Then bring the services up and load a pre-existing database dump in the new container.

Right after that, bring the db up to date with the command `php bin/console mautic:update:apply --finish`.

I got this far but I got stuck on this error I can’t make sense of:

```auto
[error] Migration Mautic\Migrations\Version20230522141144 failed during Pre-Checks. Error: "Unknown column type "json_array" requested. Any Doctrine type that you use has to be registered with \Doctrine\DBAL\Types\Type::addType(). You can get a list of all the known types with \Doctrine\DBAL\Types\Type::getTypesMap(). If this error occurs during database introspection then you might have forgotten to register all database types for a Doctrine Type. Use AbstractPlatform#registerDoctrineTypeMapping() or have your custom types implement Type#getMappedDatabaseTypes(). If the type name is empty you might have a problem with the cache or forgot some mapping information."

In Exception.php line 115:
                                                                                                                                                                                                                                             
  Unknown column type "json_array" requested. Any Doctrine type that you use has to be registered with \Doctrine\DBAL\Types\Type::addType(). You can get a list of all the known types with \Doctrine\DBAL\Types\Type::getTypesMap(). If th  
  is error occurs during database introspection then you might have forgotten to register all database types for a Doctrine Type. Use AbstractPlatform#registerDoctrineTypeMapping() or have your custom types implement Type#getMappedData  
  baseTypes(). If the type name is empty you might have a problem with the cache or forgot some mapping information.

```

Any pointer here will be highly appreciated.

Thanks!

---

<div class="post-metadata">

**Author:** ![mchojrin](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/mchojrin/32/10159_2.png) [@mchojrin](https://forum.mautic.org/u/mchojrin)\
**Post date:** [February 26, 2024, 4:57pm UTC](https://forum.mautic.org/t/guide-to-upgrading-from-v4-to-v5-on-docker/30801/3 "2024-02-26T16:57:09Z")

</div>

Hey everyone. After a long list of unsuccesful experiments I think I have somewhat of a recipe for this upgrade.

What I did:

1. Clone [the repository](https://github.com/mautic/docker-mautic) locally
2. Took a dump of my prod database (v4)
3. Made a copy of my server configuration (`docker cp mautic.ssl:/var/www/html/app/config/local.php`)
4. Copy the file from the server to my local
5. Brought the services up using the basic example (`docker-compose -f examples/basic/docker-compose.yml up`)
6. Imported the production database into the local container (`docker-compose -f examples/basic/docker-compose.yml exec -T db mysql -u mautic_db_user -pmautic_db_pwd mautic_db < mautic.dump.sql`)
7. Run the migrations from within the local container (`docker-compose -f examples/basic/docker-compose.yml exec php bin/console mautic:update:apply --finish`)
8. Adjusted the local config  
8.1 Replaced the prod URL with localhost  
8.2 Replaced the v4 directories (`app/*` for the structure used in v5)  
8.3 Added localhost as trusted\_host

After this I was able to visit my local site and have version 5.0.3 working.

I didn’t copy my files nor dashboards but I believe that had I done that it would have worked.

I hope this helps. Haven’t done the full migration in prod, I hope I get to do it soon.

Regards,

---

<div class="post-metadata">

**Author:** ![alexk1919](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/alexk1919/32/12270_2.png) [@alexk1919](https://forum.mautic.org/u/alexk1919)\
**Post date:** [July 3, 2024, 1:57am UTC](https://forum.mautic.org/t/guide-to-upgrading-from-v4-to-v5-on-docker/30801/4 "2024-07-03T01:57:36Z")

</div>

> [@mchojrin](#):
>
> I didn’t copy my files nor dashboards but I believe that had I done that it would have worked.
> 
> I hope this helps. Haven’t done the full migration in prod, I hope I get to do it soon.

Hi, can you confirmed that this works?  
I am new to Mautic and am having an issue with the database not persisting when I update the mautic web container.

I have a separate container for mariadb.

And want to persist the local.php, media files and database.

But every time, it tries to run the setup page on deploy.

HEre is my compose file for mautic:

version: ‘3.8’

services:  
rabbitmq:  
image: rabbitmq:3  
container\_name: rabbitmq.kbb-mautic-docker  
environment:  
- RABBITMQ\_DEFAULT\_VHOST=${RABBITMQ\_DEFAULT\_VHOST}  
volumes:  
- rabbitmq-data:/var/lib/rabbitmq  
networks:  
- a0scg4s

mautic\_web:  
image: mautic/mautic  
container\_name: mautic\_web.kbb-mautic-docker  
ports:  
- 8003:80  
volumes:  
- ./mautic/config:/var/www/html/config:z  
- ./mautic/logs:/var/www/html/var/logs:z  
- ./mautic/media/files:/var/www/html/docroot/media/files:z  
- ./mautic/media/images:/var/www/html/docroot/media/images:z  
- ./cron:/opt/mautic/cron:z  
- mautic-certificates:/etc/letsencrypt # Ensure certificates are persistent  
- mautic-config:/var/www/html/app/config # Ensure configuration is persistent  
environment:  
- DOCKER\_MAUTIC\_LOAD\_TEST\_DATA=${DOCKER\_MAUTIC\_LOAD\_TEST\_DATA}  
- DOCKER\_MAUTIC\_RUN\_MIGRATIONS=${DOCKER\_MAUTIC\_RUN\_MIGRATIONS}  
- MAUTIC\_DB\_HOST=db-a0scg4s  
- MAUTIC\_DB\_PORT=3306  
- MAUTIC\_DB\_NAME=${MAUTIC\_DB\_NAME}  
- MAUTIC\_DB\_USER=${MAUTIC\_DB\_USER}  
- MAUTIC\_DB\_PASSWORD=${MAUTIC\_DB\_PASSWORD}  
healthcheck:  
test: [“CMD-SHELL”, “curl -f [http://localhost](http://localhost) || exit 1”]  
start\_period: 30s  
interval: 30s  
timeout: 10s  
retries: 3  
networks:  
- a0scg4s

mautic\_cron:  
image: mautic/mautic  
container\_name: mautic\_cron.kbb-mautic-docker  
volumes:  
- ./mautic/config:/var/www/html/config:z  
- ./mautic/logs:/var/www/html/var/logs:z  
- ./mautic/media/files:/var/www/html/docroot/media/files:z  
- ./mautic/media/images:/var/www/html/docroot/media/images:z  
- ./cron:/opt/mautic/cron:z  
- mautic-config:/var/www/html/app/config # Ensure configuration is persistent  
environment:  
- DOCKER\_MAUTIC\_ROLE=mautic\_cron  
- MAUTIC\_DB\_HOST=db-a0scg4s  
- MAUTIC\_DB\_PORT=3306  
- MAUTIC\_DB\_NAME=${MAUTIC\_DB\_NAME}  
- MAUTIC\_DB\_USER=${MAUTIC\_DB\_USER}  
- MAUTIC\_DB\_PASSWORD=${MAUTIC\_DB\_PASSWORD}  
depends\_on:  
mautic\_web:  
condition: service\_healthy  
networks:  
- a0scg4s

mautic\_worker:  
image: mautic/mautic  
container\_name: mautic\_worker.kbb-mautic-docker  
volumes:  
- ./mautic/config:/var/www/html/config:z  
- ./mautic/logs:/var/www/html/var/logs:z  
- ./mautic/media/files:/var/www/html/docroot/media/files:z  
- ./mautic/media/images:/var/www/html/docroot/media/images:z  
- ./cron:/opt/mautic/cron:z  
- mautic-config:/var/www/html/app/config # Ensure configuration is persistent  
environment:  
- DOCKER\_MAUTIC\_ROLE=mautic\_worker  
- MAUTIC\_DB\_HOST=db-a0scg4s  
- MAUTIC\_DB\_PORT=3306  
- MAUTIC\_DB\_NAME=${MAUTIC\_DB\_NAME}  
- MAUTIC\_DB\_USER=${MAUTIC\_DB\_USER}  
- MAUTIC\_DB\_PASSWORD=${MAUTIC\_DB\_PASSWORD}  
depends\_on:  
mautic\_web:  
condition: service\_healthy  
networks:  
- a0scg4s

volumes:  
rabbitmq-data:  
mautic-certificates:  
mautic-config:

networks:  
a0scg4s:  
external: true
