We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 53769
    • 2 Posts
    Hi.

    I'm currently trying to setup a deployment using docker swarm and modx (2.5.2). For this I'm using the modx docker image. My plan would be, to have only one modx mysql instance and several modx instances deployed to different nodes to be able to load balance. In theory this should work out, but I'm currently struggling with the fact, that as soon as a second node is starting up, it tries to setup a new database and fails with "Table prefix is already in use in this database!". This would be fine (since there's already a setup modx DB instance created by the first node), if it wouldn't leave the setup in an uninitalized state. That means especially, that the config.inc.php is empty and invoking modx leads to a failure then, regarding XPDO.

    So my question is, what would be the easiest way to accomplish this? I already looked into the installer code where the database is checked first (this is where it dies), and after that the config is created. So it's reasonable that the config.inc.php hasn't been created yet. Would it be as "simple" as moving the config creation part before the database check? So that the setup parameters from the config.xml are already transformed to the config.inc.php and then it exits with "already exists"? But then no cleanup of the setup would be done as well, right? Maybe I could do this manually then. Any hints how to tackle this?

    Thanks!
      • 22303 MODX Staff
      • 10,725 Posts
      Just copy the already installed instance to any additional nodes. You don't want to run setup again on the same database.
        • 53769
        • 2 Posts
        Thanks for the quick reply!

        Unfortunately docker doesn't work that way. The idea behind it is, to rollout the identical images multiple times to different nodes and not to copy stuff from node to node, from one docker image to another smiley. The modx docker image seems to be designed to install a new database everytime - altough an installation might already existing (in DB). For us the modx installation that is rolledout e.g. to prod is a "read-only", "throw-away" instance where nobody will actively work on - e.g. in manager. Instead we have a master that is exported via Gitify and put into a docker image. Then on container startup, the exported files are imported (once) into the new modx instance - using Gitify again. This works quite flawless and allows us to setup and destroy an instance as we please. Is there any existing way to get a new modx installation running using an existing DB? Is it just getting the config.xml to config.inc.php an that's it? Or are there other things that must be setup in order to get it running? Since we're installing plugins using Gitify, I guess these will create another problem, since the DB entries are already there, but the plugin files on the filesytem might be missing? If you say this will be a never ending story, we have to rethink the way we rollout multiple nodes sad...