How to upgrade Mautic 5 to 5 or 6 inside a docker container?

Your software
My Mautic version is: Not sure anymore - some 5.0 or similar
My PHP version is: Official Mautic docker 5 image
My Database type and version is: Same - Official Mautic docker

Your problem
My problem is:
I believe I’ve upgraded my docker container the docker way.
My docker-compose.yaml contains (a few months old and working for a few months as well):

  mautic_web:
    image: mautic/mautic:5-apache

Then I’ve done (I believe):

docker compose stop
docker compose pull
docker compose up

Now, I should have a new Mautic version with an old DB?
I get a 500 error message in the browser and see this one in the logs:

[2025-07-13T05:45:01.317212+00:00] mautic.ERROR: Doctrine\DBAL\Exception\InvalidFieldNameException: An exception occurred while executing a query: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'c0_.deleted' in 'SELECT' (uncaught exception) at /var/www/html/vendor/doctrine/dbal/src/Driver/API/MySQL/ExceptionConverter.php line 67 while running console command `mautic:campaigns:rebuild` [stack trace] #0 /var/www/html/vendor/doctrine/dbal/src/Connection.php(1938): Doctrine\DBAL\Driver\API\MySQL\ExceptionConverter->convert(Object(Doctrine\DBAL\Driver\PDO\Exception), Object(Doctrine\DBAL\Query)) #1 /var/www/html/vendor/doctrine/dbal/src/Connection.php(1880): Doctrine\DBAL\Connection->handleDriverException(Object(Doctrine\DBAL\Driver\PDO\Exception), Object(Doctrine\DBAL\Query)) #2 /var/www/html/vendor/doctrine/dbal/src/Connection.php(1105): Doctrine\DBAL\Connection->convertExceptionDuringQuery(Object(Doctrine\DBAL\Driver\PDO\Exception), 'SELECT c0_.is_p...', Array, Array) #3 /var/www/html/vendor/doctrine/orm/src/Query/Exec/FinalizedSelectExecutor.php(31): Doctrine\DBAL\Connection->executeQuery('SELECT c0_.is_p...', Array, Array, NULL) #4 /var/www/html/vendor/doctrine/orm/src/Query.php(330): Doctrine\ORM\Query\Exec\FinalizedSelectExecutor->execute(Object(Mautic\CoreBundle\Doctrine\Connection\ConnectionWrapper), Array, Array) #5 /var/www/html/vendor/doctrine/orm/src/AbstractQuery.php(1151): Doctrine\ORM\Query->_doExecute() #6 /var/www/html/vendor/doctrine/orm/src/Query.php(748): Doctrine\ORM\AbstractQuery->toIterable(Array, 1) #7 /var/www/html/docroot/app/bundles/CoreBundle/Entity/CommonRepository.php(380): Doctrine\ORM\Query->toIterable(Array, 1) #8 /var/www/html/docroot/app/bundles/CampaignBundle/Entity/CampaignRepository.php(37): Mautic\CoreBundle\Entity\CommonRepository->getEntities(Array) #9 /var/www/html/docroot/app/bundles/CampaignBundle/Command/UpdateLeadCampaignsCommand.php(162): Mautic\CampaignBundle\Entity\CampaignRepository->getEntities(Array) #10 /var/www/html/vendor/symfony/console/Command/Command.php(298): Mautic\CampaignBundle\Command\UpdateLeadCampaignsCommand->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput)) #11 /var/www/html/vendor/symfony/console/Application.php(1058): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput)) #12 /var/www/html/vendor/symfony/framework-bundle/Console/Application.php(96): Symfony\Component\Console\Application->doRunCommand(Object(Mautic\CampaignBundle\Command\UpdateLeadCampaignsCommand), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput)) #13 /var/www/html/vendor/symfony/console/Application.php(301): Symfony\Bundle\FrameworkBundle\Console\Application->doRunCommand(Object(Mautic\CampaignBundle\Command\UpdateLeadCampaignsCommand), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput)) #14 /var/www/html/vendor/symfony/framework-bundle/Console/Application.php(82): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput)) #15 /var/www/html/vendor/symfony/console/Application.php(171): Symfony\Bundle\FrameworkBundle\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput)) #16 /var/www/html/bin/console(16): Symfony\Component\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput)) #17 {main} [] {"hostname":"b872de7f00b9","pid":443}

Not sure, whether it is related?
Any idea on how to solve this?

@Chris76 I’ve moved this to Product Support > Docker support as that seems to be a more appropriate place for it.

It seems the migrations weren’t executed. Please run bin/console doctrine:migrations:migrate inside the docker container.

Hello @escopecz

thanks for your reply.

There are 3 containers:
mautic_cron-1
mautic_worker-1
mautic_web-1

So I tried in the web first:

docker exec -it bae2d0218b24  php /var/www/html/bin/console doctrine:migrations:status
docker exec -it bae2d0218b24  php /var/www/html/bin/console cache:clear

that seem to have worked somewhat.
Afterwards, I was able to login and see some details - but it seems like, some CSS / cache issue remained:

So I checked the upgrade guide to search for help and details.

and figured, I’d try to upgrade / go through the process - now moving on to Mautic 6

docker exec -it bae2d0218b24  php /var/www/html/bin/console mautic:update:find
docker exec -it bae2d0218b24  php /var/www/html/bin/console mautic:update:apply
docker exec -it bae2d0218b24  php /var/www/html/bin/console mautic:update:apply --finish

[17-Jul-2025 20:40:29 UTC] PHP Fatal error:  Type of Mautic\ApiBundle\Entity\oAuth2\Client::$randomId must not be defined (as in class FOS\OAuthServerBundle\Model\Client) in /var/www/html/docroot/app/bundles/ApiBundle/Entity/oAuth2/Client.php on line 15

Fatal error: Type of Mautic\ApiBundle\Entity\oAuth2\Client::$randomId must not be defined (as in class FOS\OAuthServerBundle\Model\Client) in /var/www/html/docroot/app/bundles/ApiBundle/Entity/oAuth2/Client.php on line 15

How to get out of this situation?
The result so far is definitely worse:

From the error message it seems like the Mautic code does not fit the installed libraries versions. Do you have composer available in the container? Is composer --version returning something?

Seems as if the official docker image doesn’t contain composer (at least on in the $PATH):

docker exec -it bae2d0218b24  composer --version
OCI runtime exec failed: exec failed: unable to start container process: exec: "composer": executable file not found in $PATH: unknown

Is docker the way to go, or would I better avoid docker, if it can’t be upgraded the “docker way” anyway?

However, I’ve tried to progress:

$ docker exec -it bae2d0218b24  php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
$ docker exec -it bae2d0218b24  php composer-setup.php
All settings correct for using Composer
Downloading...

Composer (version 2.8.10) successfully installed to: /var/www/html/docroot/composer.phar
Use it: php composer.phar

$ docker exec -it bae2d0218b24  mv composer.phar /usr/local/bin/composer
$ docker exec -it bae2d0218b24  composer --version
Composer version 2.8.10 2025-07-10 19:08:33
PHP version 8.1.32 (/usr/local/bin/php)
Run the "diagnose" command to get more detailed diagnostics output.

$ docker exec -it bae2d0218b24  composer update
Loading composer repositories with package information

In Git.php line 592:
                                                                                                                                          
  Failed to clone https://github.com/mautic/SymfonyBridgeBundle.git, git was not found, check that it is installed and in your PATH env.  
                                                                                                                                          
  sh: 1: exec: git: not found                                                                                                             
                                                                                                                                          

Then I get stuck in the “slim” Linux for the container.
That’s why I doubt the Docker approach here - either I’m doing this very wrong or the whole thing isn’t “made” for being in Docker?
(Compare a MySQL or PHP container / version upgrade)

You may have to get into the container and execute composer install there. Please do not use composer update as it could download untested libraries.

Although I’m not sure this is the right approach to update Docker. I’ve linked this form thread in the docker Slack channel to get more eyes from Docker experts here. The Docker images are meant to be immutable. Once you upgrade to a new Docker image it shoudn’t require file changes. Just running the database migrations as the migrations are stored in a volume, not the docker image.