Got it! You want a Dockerized WordPress project that runs locally with HTTPS on a custom domain https://example.com, and later you’ll move it to shared hosting. Let’s go step by step. I’ll include Docker, HTTPS setup for local development, and WordPress configuration.
Create a project folder, e.g., wordpress-docker:
wordpress-docker/
│
├─ docker-compose.yml
├─ nginx/
│ └─ default.conf
├─ certs/ # for self-signed SSL
└─ html/ # WordPress files (will be mounted)docker-compose.yml:
services:
wordpress:
image: wordpress:latest
container_name: wordpress
restart: always
environment:
WORDPRESS_DB_HOST: db:3306
WORDPRESS_DB_USER: wpuser
WORDPRESS_DB_PASSWORD: wppassword
WORDPRESS_DB_NAME: wpdatabase
volumes:
- ./html:/var/www/html
expose:
- "80"
db:
image: mysql:5.7
container_name: db
restart: always
environment:
MYSQL_DATABASE: wpdatabase
MYSQL_USER: wpuser
MYSQL_PASSWORD: wppassword
MYSQL_ROOT_PASSWORD: rootpwd
volumes:
- db_data:/var/lib/mysql
ports:
- "3306:3306"
nginx:
image: nginx:latest
container_name: nginx
restart: always
ports:
- "443:443"
- "80:80"
volumes:
- ./nginx/default.conf:/etc/nginx/conf.d/default.conf
- ./certs:/certs
- ./html:/var/www/html
depends_on:
- wordpress
volumes:
db_data: {}nginx/default.conf:
server {
listen 443 ssl;
server_name example.com;
ssl_certificate /etc/nginx/certs/cert.pem;
ssl_certificate_key /etc/nginx/certs/key.pem;
root /var/www/html;
index index.php index.html index.htm;
location / {
try_files $uri $uri/ /index.php?$args;
}
location ~ \.php$ {
include fastcgi_params;
fastcgi_pass wordpress:80;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
}
mkdir certs
openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout certs/key.pem -out certs/cert.pem
Common Name (CN): example.com
Add the following line to /etc/hosts (Linux/macOS) or C:\Windows\System32\drivers\etc\hosts (Windows):
127.0.0.1 example.com
This maps your custom domain to localhost.
docker-compose up -d
- WordPress will be accessible at: https://example.com
- Database: wpdatabase / wpuser / wppassword
- PHP handled via Nginx container.
When you move to shared hosting:
-
Export WordPress files from
./html. -
Export the MySQL database from
db_data:
docker exec db mysqldump -u wpuser -p wpdatabase > wpdatabase.sql
- Upload both to your hosting provider.
- Update
wp-config.phpwith your shared hosting DB credentials.