Skip to content


Repository files navigation


Wordpress configured in docker-compose


  • Add an ENV BACKUP_CMD=mysqldump -uxxx -pjjj --database xxxx > xxx.sql && tar -czf /tmp/backup.tar.gz xxx which always generates a backup.tar.gz under /tmp.
  • Add an ENV RESTORE_CMD=xxx.

How to use this repo


Basic steps:

  • [1] Open up docker-compose.yml
    • [1.1] Change those fields filled with <CHANGE_ME> and save it.
    • [1.2] Change DOMAIN.tld to the exact domain and remove redundancy, save it.
  • [2] Run sudo docker-compose up -d to get the whole server up and running.


  • [1.1] Copy .env.sample to .env, then edit it to specify an NGINX profile location, you can also leave it blank.

Optional processes:

  • [2.3] In the app root, run the command from nginx-gen service in the compose file. This is useful if you want to update the nginx.tmpl file.

Let's Encrypted integrated

HTTPS Enabled

When you done all steps above, your website will have HTTPS enabled already.

Integrate with other apps on the same server

If you are running other apps on the same server, the nginx inside this docker-compose must be able to talk to that app. So you need to have an external network.

In each docker-compose.yml, add an external network:

      name: nginx-proxy

Then in your apps, hook this proxy-tier up like this (within an service):

  - proxy-tier

Then setup those apps just like this docker-compose/wp, add envs such as VIRTUAL_HOST, LETSENCRYPT_HOST. Then you can recreate your app to make it work.


Nginx Config

If you want to config nginx per-vhost, use below command:

# Replace <CHANGE_ME> with your exact domain name.
# However, if you have multiple domains bound to one service, 
#   refer to
# If it does NOT work, append to `/etc/nginx/vhost.d/default`
sudo docker exec -it nginx sh -c "{ echo 'server_tokens off;'; echo 'client_max_body_size 10m;'; } > /etc/nginx/vhost.d/<CHANGE_ME>"

Wordpress Config

  • Increase upload file size: php_value upload_max_filesize 30M

You only want an nginx

sudo docker-compose up -d nginx

How the built environment is structured?

The data:

Key information: data volumes are specified in docker-compose.yml > volumes section.

$ sudo docker volume ls

local               wordpressdockercompose_db_data
local               wordpressdockercompose_db_etc_mysql
local               wordpressdockercompose_wp_data

Backup and restore

Docker setup

Create the apps (empty)

# Install Docker
curl -sSL | sudo sh

# Install Docker Compose
sudo su # Enter su mode
curl -L`uname -s`-`uname -m` > /usr/local/bin/docker-compose && chmod +x /usr/local/bin/docker-compose
exit # Exit from su

# Create app (empty)
sudo docker-compose up

# After it's initialized, stop it with Ctrl + C, ready for restoring.

Restore from volume backup files

# Restore
# Usually, <BACKUP_PATH> can be `pwd`/backups

# To print restore commands only
sudo ./ <BACKUP_PATH>/20XX-XX-XX-XX-XX-XX --print


# Backup
sudo ./

# Rackspace Cloud Files
# sudo su
curl -L > /usr/local/bin/rack && chmod +x /usr/local/bin/rack
rack configure
rack files object upload --container DO_NOT_DELETE_LS_BACKUP --region HKG --name <PROJ_NAME>/<TAR_FILE_NAME>-backup.`date +"%Y-%m-%d-%H-%M-%S"`.tar.gz --file <TAR_PATH>

You are free to use any cloud file storages, just backup that <TAR_PATH> thing.




No releases published


No packages published