Take out my wordpress site and move it to wordpress inside docker?

Hi,

Sorry if this is a noob-question, but I’ve been using Hestia for a few months and it’s super-easy, both for wordpress + email-server. But I’m also interested in kubernetes, docker etc so now my idea is that I would like to copy or take out the wordpress site from the existing installation and move it into a docker-container - or maybe I just run an existing wordpress-docker container and copy over the data files from hestia CP (which folders to copy)?

If I figure out how that works I can run k3s and experiment with load balancing - hopefully, right?

I’ve tried to google and search and I did find something related to what I want: Project to run Hestia in Docker - #10 by jhmaverick - and I might also need: Web domains and SSL Certicates — Hestia Control Panel documentation - but it’s still not clear for me if this is possible/easy or if there are problems doing it?

If I do this, the next problem to solve is extracting the email-server data so I also can run that on docker so I can load-balance the mailserver and e.g. upgrade and reboot the mailserver without downtime… In the end it means I’ll stop using Hestia-CP, but without losing my existing Hestia-data (wordpress data + mail data)… Could anyone please give your input/recommendations/thoughts to this project?

Thanks!

For a full wp migration you need:

  • PHP code: WordPress itself, plugins, themes, wp-content - usually all the public_html files
  • Database: full database backup
  • Adapt the database connection to the new install by editing wp-config php

For email use imapsync

Thanks, yes email I don’t think will be a problem in any case (otherwise I think I once dragged and dropped from folder to folder within thunderbird)… Wordpress migration, I’m worried about…

That’s great advice, thanks! Do you happen to know exactly which folders I should copy over and overwrite from HestiaCP to a (hopefully similar) fresh wordpress-installation inside a docker-container (sorry if it’s a noob question, just trying to save a lot of hours in case I do something wrong)?

Get all the content of the public_html directory in a zipfile

And all the content of the database on a zipfile

Alternatively, you may install a clean wordpress and only copy the WP content folder. Beware that if the WordPress install is not up to date, you may have trouble with incompatibilities between the WP version and the plugins or themes.

Thanks a lot, it sounds sane! This reply will be a bit long and document what I’ve done, maybe it can help someone in the future, in the same situation if I succeed properly with this… Please let me know if something is wrong or could be improved:

About web-server migrating:

  • I followed your suggestion and zipped the public_html-folder and downloaded it.

  • I logged into the admin-page of wordpress, for the webdomain and it’s running WordPress 6.1.1. I ran “docker pull wordpress” and I know it’s wrong, because I didn’t do anything about the database yet - but I just tried:
    docker run --name local-wordpress -p 8080:80 -d wordpress

  • I connected to localhost:8080 and it became clear that: Database name, Database username, Database password, Database host, Table prefix (for running more than one WordPress in a single database) - all is used to create the public_html/wp-config.php file.

  • In the case of hestiaCP, DB_HOST was/is localhost, so I should figure out if it’s possible/reasonable for me to have the database in the same docker-container and because I would like to experiment with kubernetes (actually lightweight: k3s), I think it’s best for me to now separate the database from the wordpress-container. I found an excellent article here, I think I can use: How to Easily Setup Wordpress Using Docker | by Habib Ridho | Medium

  • Now, I was wondering: Which mysql version is hestia running, so I can grab rougly the same docker-container and version?

  • I typed: mysql as root and it replied with some lines e.g. Your MariaDB connection id is 502 ; Server version: 10.6.12-MariaDB-0ubuntu0.22.04.1 Ubuntu 22.04

  • I googled a bit more and realized hestia is not using mysql, but mariaDB - which doesn’t sound bad at all (from google): “MariaDB is still completely open-source, while MySQL now has closed-source modules. Overall, MariaDB delivers better performance, is faster and more lightweight than MySQL…”. In theory I suppose I needed MariaDB v.10.6.12, but I’m crossing my fingers and hoping that mariadb:latest is just as good…

  • I typed:
    docker run --detach --name mariadb --env MARIADB_USER=(from-public_html/wp-config.php:DB_USER) --env MARIADB_PASSWORD=(from-public_html/wp-config.php:DB_PASSWORD) --env MARIADB_ROOT_PASSWORD=1234 -p 3306:3306 -d mariadb:latest
    … it took a while to figure out I needed MARIADB_ROOT_PASSWORD=1234 - and I don’t know what the value for MARIADB_ROOT_PASSWORD is in hestiaCP or where I see it, so I just set it to 1234 for now - maybe it doesn’t matter?

  • Now I can write: “docker logs mariadb” and it responds with version 10.11.2 - a bit ahead of the 10.6.12 from HestiaCP - hopefully allright…

  • This is the time I realized I needed to extract the database from HestiaCP. I couldn’t figure out which folder to copy, so I used the webinterface and tried phpmyadmin - resulting in a “Page Not Found”, probably because I misconfigured something. Searched the forums and removed the leading “hcp.” from “hcp.(domain-name)/phpmyadmin/” and it worked.

  • I logged into phpmyadmin using the data from wp-config.php - and found the “Export”-tab, where I left the default at “Quick” + clicked “Export” and I downloaded a “localhost.sql”-text/ASCII-file: “phpMyAdmin SQL Dump – version 5.2.0” to my local pc.

I think there are 3-4 web-server issues left for me to solve over the next days and hopefully I’ll solve it:

  1. I need to map a persistent folder to my host-machine, from the wordpress-container so it writes/updates public_html on the hostmachine and the container sees the same files - but this should be easy, because then I just extract and manually copy over all the public_html-files which I’ve zipped and downloaded and it’s just basic fileoperations, after the directory mapping is done (-v option to docker, just need the proper arguments).
  2. I need to figure out how to import that database-stuff into the mariadb-docker container and I probably need to map a persistent folder to my host-machine, from mariadb… This is something I’m not experienced with - I need to figure out what to do with the “localhost.sql”-file and how I import it into the mariadb-docker container… Anyone got any hints/clues?
  3. The DB_HOST-value was localhost when it was used inside hestiaCP. With a separate mariadb container, this probably must be the IP-address of the maria-DB-docker… Which leads to the next related problem, I need to understand/consider:
  4. Finally I think I need to setup networking properly (or at least convince myself if it’s okay) because currently I don’t think the wordpress docker-database can see the ports exposed by the mariadb-container - with -p 8080:80 for the wordpress-container and -p 3306:3306 for the mariadb-container…

About mail-server migrating:
I just looked into /home/(user-name)/mail/(domain) and there are some dovecot-filenames. This makes me think that maybe I can just copy that data into a container such as that for dovecot, see link: Docker - and then apply a similar procedure as above, for the webserver regarding creating a persistent folder and exposing the correct ports (this probably needs several ports exposed)…

I appreciate if anyone has feedback or if I’m doing something I shouldn’t - or if I’m on the right track, which I hope :smile:

1 Like