Welcome to part 2. Time to move the next steps, and complete the migration. By the time we are done, we will have:
- External facing NGINX container proxying to the internal WordPress instance.
- SSL certificate issuing and renewals with a companion container
- A WordPress container with your site migrated
- A MariaDB database container containing your migrated database
Enough talking, let’s get to work!
Create the New WordPress User
Open a shell into the new server which has docker and docker-compose available and running. To install docker and docker compose, follow the instructions here.
Let’s assume that the name of the system user running wordpress is wpuser. In order to create the user, run the following command:
sudo useradd -s /bin/bash -m wpuser
This will create the user without assigning a password. I would recommend running this way, should you want to assign a password, use the passwd command. This article assumes that will will use “sudo” to switch to the wpuser account without actually logging in as wpuser. In order to switch account, use the following command.
Now it’s time to add wpuser to the docker group, so that wpuser can issue docker commands. We would simply add the user wpuser to the docker group with the following command.
sudo usermod -a -G docker wpuser
Now, let’s switch to the wpuser with the following command:
sudo -i -u wpuser
If the command prompts you for a password, use your password to authorized the sudo command. If the command fails, look at the sudo documentation to resolve the problems.
Let’s make sure that the user wpuser can run docker commands with the following command:
docker version
Assuming everything goes ok, you will see the output of the different component versions. If something is wrong, you might want to look at the error and understand what could have gone wrong. Also, you could revisit the commands to create the user and assign the right permissions.
Now it’s time to move on and actually creating the docker images with docker-compose.
Create Nginx, WordPress, and MariaDB Container Images
It’s time to choose if this installation will be a brand new one, or a migration of an existing WordPress + Database.