Docker Community Forums

Share and learn in the Docker community.

Copy wordpress hosting site to home computer

I’m running the latest version Docker on WSL2 in Windows 10.
What my goal is to copy my inmotionhosting website to my home computer into a docker container. Then copy the wordpress, import the database. My goal is to run the “production” wordpress in Docker.

I’ve found tons of help creating wordpress, mysql, phpmyadmin containers. Using suggested docker-compose .yml I can get to wordpress, mysql and phpmyadmin. But have no clue how to use my copied wordpress files.

One big problem is the directory structure of my hosting service is different from my wsl system. Watching the compose file start up. I see it’s referencing /var/www/html. Doesn’t exit. I created and my files there. Apparently is was ignored. My docker-compose files is below. The result form this is results in complaints about unable to read .htaccess.

I’ve tried many suggestions from google, none worked.

Is there a guide I can follow to help me?

Thanks so much.

version: ‘3’

services:

Database

db:
image: mysql:5.7
volumes:
- db_data:/var/lib/mysql
restart: always
environment:
MYSQL_ROOT_PASSWORD: wordpress
MYSQL_DATABASE: wordpress
MYSQL_USER: wordpress
MYSQL_PASSWORD: wordpress
networks:
- wpsite

phpmyadmin

phpmyadmin:
depends_on:
- db
image: phpmyadmin/phpmyadmin
restart: always
ports:
- ‘8080:80’
environment:
PMA_HOST: db
MYSQL_ROOT_PASSWORD: password
networks:
- wpsite

Wordpress

wordpress:
depends_on:
- db
image: wordpress:latest
ports:
- ‘8000:80’
restart: always
volumes: [’./:/var/www/html’]
environment:
WORDPRESS_DB_HOST: db:3306
WORDPRESS_DB_USER: wordpress
WORDPRESS_DB_PASSWORD: wordpress
networks:
- wpsite
networks:
wpsite:
volumes:
db_data:

Maybe you should use a plugin like UpdraftPlus to create a backup of your original site and to restore it to your container.

Thanks. I’ll check it out. I use BoldGrid which has that function but it assumes the restore site has the same directory structure. I’ll check out your suggestions.

I recommend this article, which I have successfully adapted. You should map /var/www/html and /var/www/html/sites/default/files on the PHP container to host folders, and /var/lib/mysql and /var/files on the MySQL container:

How to use PHP, Apache, MySQL within Docker containers
https://www.cloudreach.com/en/resources/blog/containerize-this-how-to-use-php-apache-mysql-within-docker-containers/

Thanks so much. After hours of going through google links, I finally stumbled upon the link. It all seemed so obvious :slight_smile:
Thanks for your help