A guide to running dockerised wordpress on Synology
I have been curious about using docker on my Synology for hosting (very) small/low traffic sites and pages. I have successfully served flat sites built using HUGO and ghost, but have always struggled with running separate publishing and databases using docker. Synology offers both MariaDB and Wordpress via the package center, but for those looking for a docker based solution this guide is intended to help. Mileage may vary, let me know how you get on.
From the package center - Install docker on your Synology
Open up docker and from the registry tab search for mariadb - I chose the latest official MariaDB community docker image:
While you are here also grab the official latest wordpress image:
I named the maria image as wordpressdb and wordpress - call them whatever makes sense to you.
Next up you need to create a folder on your Synology to "store" the data. You will need a folder for the database (sql) and the wp (html) files:
Synology Docker Steps
The Synology docker package requires a bit of understanding as it abstracts the compose files. First up the Maria settings.
#1. Maria - General Settings
Give your container a name: wordpressdb
Choose how you want the container to behave - limit resources, auto restart, etc...
#2. Maria - Volume
Under the volume tab you need to "map" the container to the folder that you created locally on your synology:
#3. Maria - Port Settings
Since we will be using names, you can leave this tab as Auto
#4. Maria - Links
Leave this empty
#5. Maria - Environment
This is where you need to choose & specify:
This should allow you to start your container from the control panel. When you click on the details tab - you should be able to view the log, and you can see each step complete successfully :
You should also be able to see the database files in your local folder, including the database that you created above:
Due to the way that the db is initialised - it can take a bit of time for your database to be created (a couple of minutes).
Now it's time to set up the Wordpress container using the Docker package:
#6. Wordpress - General Settings
#7. Wordpress - Volume
Again, we need to connect the container to the folder that you created on your Synology for the Wordpress content:
#UPDATED: if you need to upload themes which are natively too large to handle then you will need to create a ini.php with additional parameters and then mount the file here:
file_uploads = On
memory_limit = 256M
upload_max_filesize = 128M
post_max_size = 256M
max_execution_time = 300
max_input_vars = 5000
#8. Wordpress - Port Settings
Since you will want to be able to access your Wordpress site from the web, you will need to specify a port to connect to port 80 on the container:
This step is necessary for setting up the SSL certificate and reverse proxy settings later on...
#9. Wordpress - Links
The tab allows your Wordpress site to use the Maria container that we have already set up. Wordpress is looking for a "mysql" instance so we need to link our Maria container (wordpressdb) to Wordpress' mysql:
#10. Wordpress - Environment
Once again you now need to "tell" Wordpress how to connect to the Maria instance... You should specify the details that we created at #5:
WORDPRESS_DB_HOST: the_container_name_for_your_DB (from step #1)
WORDPRESS_DB_NAME: name_of_your_database (from step #5)
WORDPRESS_DB_USER: user_name (from step #5)
WORDPRESS_DB_PASSWORD: user_password (from step #5)
Go ahead and start your container from the docker package and you should be able to view the successful log and wp files created in your local folder.
You should now be able to access your WP site using the IP address of your Synology : the port that you chose at step #8. Eg: http://192.168.0.55:32789