How to easily manage multiple WordPress sites in Docker using Demyx

  • Sat Dec 07 2:45
  • 6 Comments
  • 343

First of all, what the heck is Demyx?

Demyx is a Docker image that automates and manages WordPress installations. Traefik for reverse proxy with Lets Encrypt SSL/TLS. WordPress sites are powered by NGINX, PHP, and MariaDB.

https://demyx.sh

Step 1. DigitalOcean

Now that’s out of the way, this article will show you a step-by-step guide on how to use Demyx. I’ve tested this briefly on Debian, Ubuntu, and CentOS; all works fine but CentOS needs some minor tweaks. I have Alpine Linux on all my servers so of course it 100% works. I’ll be using DigitalOcean for this guide, using their pre-made Docker droplet in the marketplace running Ubuntu 18.04 x64.

digitalocean.com

Step 2. No-IP

For this guide, I will also be using a free DNS service called No-IP. Great for demos, testing, and personal use if you don’t have a domain. Create your hostname and make sure you point the IP to your server. You can create up to 3 hostnames on the free plan.

noip.com

Step 3. Install

Run this command to run the install script. It will download all the necessary Docker images that Demyx uses. After it downloads the images, please fill out the prompts. After you install, you will be chrooted into the Demyx container, you will see my own MOTD (Message of the Day).

bash -c "$(curl -fsSL https://demyx.sh/install)"
Message of the Day inside the Demyx container

Step 4. WordPress

Demyx is preconfigured to always use HTTPS but since this is a demo using a subdomain, with no control on the Top Level Domain (TLD), it’s not possible to use SSL. We will be passing the --ssl=false flag. The MOTD shows two options you can use, for this example, I will be using a regular WordPress install. Don’t know what Bedrock is? Visit their site: https://roots.io/bedrock/.

# Command executed on the host OS
demyx cmd run demyx.ddns.net --ssl=false

# Command executed inside demyx
demyx run demyx.ddns.net --ssl=false

After the site installs, you will be presented with a table of useful information. To see all of the site’s settings/variables: demyx info demyx.ddns.net --all.

Short information table after site creation

Step 5. Congratulations

demyx.ddns.net

YAY! You made your first Demyx app! Notice how we didn’t touch a single Docker command? That’s because it was to make my life easier and now it can make yours a little better too!

Step 6. Multiples

Now, we need to add our other hostnames to No-IP and then create them in Demyx. Demyx also supports IP address as the “domain” during runtime.

Updated hostnames in the No-IP dashboard
WordPress with IP address as the domain
Command: demyx list

Step 7. Bonus

But wait, there’s more! Demyx comes packed with features that’s available in the help menu. I will be showing you some notable ones.

ctop

ctop is htop, but for containers! If you look at the screenshot, you can see all running containers. The ctop binary is included in the Demyx image.

# Command executed on the host OS
demyx sh ctop

# Command executed inside demyx
ctop
https://ctop.sh

code-server and browser-sync

Demyx has a feature that will turn a WordPress site into development mode. Meaning, it will turn off opcache and spin up code-server and browser-sync containers. Password auto generates every time the code-server container runs.

# Command executed on the host OS
demyx cmd config demyx.ddns.net --dev

# Command executed inside demyx
demyx config demyx.ddns.net --dev
Links to code-server and browser-sync
code-server
browser-sync

phpMyAdmin

Demyx comes shipped with phpMyAdmin that’s auto configured when running demyx config demyx.ddns.net --pma.

# Command executed on the host OS
demyx cmd config demyx.ddns.net --pma

# Command executed inside demyx
demyx config demyx.ddns.net --pma
phpMyAdmin credentials
phpMyAdmin interface

SFTP

Demyx comes with a preconfigured OpenSSH image that has root and password authentication disabled. Only accessible via public key.

# Command executed on the host OS
demyx cmd config demyx.ddns.net --sftp

# Command executed inside demyx
demyx config demyx.ddns.net --sftp
SFTP credentials
Browse site with SSH
Browse site with SFTP

Step 8. Conclusion

Demyx has a bunch of features that’s too long to list in this article so feel free to explore the help menu. If you have anymore questions, then please come join me in my channel at Freenode: #demyx.

Buy me a coffeeBuy me a coffee

Become a Patron!

6 responses to “How to easily manage multiple WordPress sites in Docker using Demyx

  • Demyx looks very interesting, I am going to check it on weekend 😉
    Do you also consider of adding features like only html site container (I’m a fan of Hugo static) or php+mysql containers?

    • Hi Arek,

      Yes I’m planning to implement support for html/php containers as soon as the commands for WordPress containers are stable. It might happen very soon! I did plan ahead and put the folder structure as a placeholder:

      https://i.imgur.com/pt6HivQ.png

      • So I tested a script and it is great, in my opinion one of the best for automation of docker and wordpress.
        But after a week, when I was trying to add another domain to the server I’m receiving message like this when I type any of demyx command:
        “error during connect: Get http://demyx_socket:2375/v1.40/containers/json: dial tcp: lookup demyx_socket on 127.0.0.11:53: no such host”
        Do you know what can cause this issue?

  • Hi,

    saw your post in the roots.io forum and looked through your code in github.
    Very nice, good work. Really like your design of your commands and the aspect of bundling tasks.
    I’m a big fan of automation scripts and played intensively with ansible for provisioning for quite a while.

    Because I looking for something like demyx, I wonder how you manage your developments and realize your deployment strategy. Are you doing your dev work and customizations via code-server directly on the server or do you make your work locally and push/sync it via git oder sftp?
    Lookin forward to hear from you.

    • Hi aarkiin,

      Thank you for the compliments! I try to be as neat as I can when coding and commenting 😊. I do everything in code-server and remotely too! I haven’t dev locally on my laptop for a long time now. As for deployment, I wrote my own bash script that chains commands.

      #!/bin/bash

      cd /demyx/web/app/themes/demyx

      # Disable module.hot.accept()
      sed -i "s|module.hot.accept|//module.hot.accept|g" /demyx/web/app/themes/demyx/resources/assets/scripts/main.js

      if [[ "$1" = push ]]; then
      git push
      else
      yarn build:production

      # Exit if build fails
      if [[ "$?" != 0 ]]; then
      echo '############################'
      echo '# #'
      echo '# BUILD FAILED! #'
      echo '# #'
      echo '############################'
      exit 1
      fi

      composer install --no-dev
      git add .
      git commit -m "$1"
      git push
      composer install
      fi

      # Enable module.hot.accept()
      sed -i "s|//module.hot.accept|module.hot.accept|g" /demyx/web/app/themes/demyx/resources/assets/scripts/main.js

      The script is chmoded and then executed via ~/deploy. If I don’t have to compile any css/js then I just commit that single file then ~/deploy push, else, it would compile. Here’s my .gitignore:

      # Include your project-specific ignores in this file
      # Read about how to use .gitignore: https://help.github.com/articles/ignoring-files
      .cache-loader
      .editorconfig
      .eslintrc.js
      .stylelintrc.js
      CHANGELOG.md
      CODE_OF_CONDUCT.md
      LICENSE.md
      README.md
      phpcs.xml
      yarn.lock
      composer.json
      composer.lock
      package-lock.json
      package.json
      node_modules
      npm-debug.log
      yarn-error.log
      resources/assets