I am trying to figure out how to setup a Wordpress development environment with Docker, such that.
1) I have a wordpress theme I wish to share via a docker image with colleagues. 2) I wish to save all data related to modifications to siad theme and changes I make to Wordpress at development time in the Docker Image so that they can get up and running with developing it further. 3) I wish to know the mechanism for them to save the data back to Docker and store the resulting file in source control (Github).
At the moment, I've been able to setup a Docker file that runs with docker-compose up
- but it doesn't save any changes made to the database, or (I more specifically I don't currently know how to do that). Reading the docs, it looks like I possibly need to 'docker commit' and then export the resulting image?
Bit confused with the concepts etc at the minute, so any help appreciated.
services:
db:
image: mysql:5.7
volumes:
- db_data:/var/lib/mysql
restart: always
environment:
MYSQL_ROOT_PASSWORD: somewordpress
MYSQL_DATABASE: wordpress
MYSQL_USER: wordpress
MYSQL_PASSWORD: wordpress
wordpress:
depends_on:
- db
image: wordpress:5.1.1-php7.3-apache
ports:
- "8001"
restart: always
environment:
WORDPRESS_DB_HOST: db:3306
WORDPRESS_DB_USER: wordpress
WORDPRESS_DB_PASSWORD: wordpress
working_dir: /var/www/html
volumes:
- ./wp-content:/var/www/html/wp-content
- ./uploads.ini:/usr/local/etc/php/conf.d/uploads.ini
volumes:
db_data:
Can you share your compose file? You can mount volumes into the wordpress docker container. Then you'd have the wordpress files in your normal FileSystem, which you then can add to Git. Mounting goes as follows:
volumes:
- /var/www/html/:/var/www/html
In order to safe your Wordpress Container, you need to Tag it via docker tag {id of wp container} your/repo:{Tag you want to add, for exmaple v1 or v2...}
and then push your container to the hub cloud via docker push your/repo:{your tag}
. From there on, your mates can pull the image from the hub and run it with all the new changes.
Hope this helps, Greetings
€: You can then just add the /wp-content folder in your yml directory to git. Also mount the db_data to a folder. Add the 3th line to your yml:
volumes:
- db_data:/var/lib/mysql
- ./mysql:/var/lib/mysql
To share database data, add volumes
option in db
service.
db:
image: mysql:5.7
restart: always
environment:
MYSQL_DATABASE: wordpress
MYSQL_USER: wpuser
MYSQL_PASSWORD: root
MYSQL_RANDOM_ROOT_PASSWORD: '1'
volumes:
- ./data:/var/lib/mysql
In most cases (develop themes or plugins), just wp-content/themes
and wp-content/plugins
are enough.
I developed a github project useful to share all data with other developers in team for that using docker-compose
based on official wordpress image.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.