[ad_1]
I’m learning how to use Docker and I’m realizing that many tutorials fail to address how to edit your WordPress project after successfully creating a container and installing WP. I’m also slowly understanding that there may be best practices with Docker and WordPress.
What are your thoughts on this topic? After WP is up and running on Docker, how should one proceed?
[ad_2]
I mount host directories into the container rather than having Docker create its own volumes. That way I can easily access the contents without diving deep into `/var/lib/docker/volumes`. Here’s my docker-compose.yml for reference:
“`
services:
db:
# We use a mariadb image which supports both amd64 & arm64 architecture
image: mariadb:latest
# If you really want to use MySQL, uncomment the following line
#image: mysql:8.0.27
command: ‘–default-authentication-plugin=mysql_native_password’
volumes:
– ./db_data:/var/lib/mysql
restart: always
environment:
– MYSQL_ROOT_PASSWORD=<PW HERE>
– MYSQL_DATABASE=wordpress
– MYSQL_USER=wordpress
– MYSQL_PASSWORD=<PW HERE>
expose:
– 3306
– 33060
wordpress:
image: wordpress:latest
volumes:
– ./wp_data:/var/www/html
– ./upload.ini:/usr/local/etc/php/conf.d/uploads.ini
ports:
– 80:80
restart: always
environment:
– WORDPRESS_DB_HOST=db
– WORDPRESS_DB_USER=wordpress
– WORDPRESS_DB_PASSWORD=<PW HERE>
– WORDPRESS_DB_NAME=wordpress
“`
The created files will be owned by the `http` user, so usually what I do is I just change the user of the theme files that I am editing to my own user and just open them up in my favorite text editor.