What is the best way to setup latest wordpress blog using docker?

Dream of any developer is to keep things portable and what would be more awesome thank to use Docker for your WordPress post right? I had plenty of hiccups in the setup like permission, portability, port and most annoying of all ssl compatibility.

Assuming that you have already installed docker-compose, you need a compose file as following.

version: '3.2'
    image: wordpress:5.2.0-php7.3-apache
    restart: always
        - "/etc/passwd:/etc/passwd:ro"
        - "/etc/group:/etc/group:ro"
        - ./wordpress/:/var/www/html/
        - 91:80
        - WORDPRESS_DB_PASSWORD=pass_is
        - APACHE_RUN_USER=my_user
        - APACHE_RUN_GROUP=my_group
    image: mysql:5.7
    restart: always
        - type: bind
          source: ./mysql
          target: /var/lib/mysql
        - MYSQL_ROOT_PASSWORD=pass_is

Solving the HTTPS – wordpress behind https proxy (ssl)

If you are using nginx behind https, you have to forward proto as https is

proxy_set_header X-Forwarded-Proto https;

server {
    listen 443 ssl;
    server_name yourdomain.com;
    index index.php index.html index.htm;
    ssl_trusted_certificate ./fullchain.pem;
    ssl_certificate ./fullchain.pem;
    ssl_certificate_key ./privkey.pem;
    root /usr/local/nginx/html/;
    location / {
        try_files $uri @app;
    location @app {
        proxy_set_header X-Forwarded-Proto https;
        include .common/proxy.common;

Back up your Blog.

sudo docker exec -it _mysql_1 mysqldump -uroot -ppass_id --all-databases > ./mysql-backup/backup.sql

Restore your Blog.

docker exec -i _mysql_1 mysql -uroot -ppass_id < ./backup.sql


  1. Embedded passwd and group file.
  2. Setting host user and group for folder permission.
  3. We are mounting wordpress folder so that your files can be added to git as well and you can work on wp-config.php without any issues.
  4. MySQL too will have data folder.
  5. You can easily move setup to different server in matters of mins.

Worth Sharing?


  1. The solution worked properly and I used proxy ssl for it. Only problem was to picking only wp-content to add to git. Otherwise all great.

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>