Do you use Docker with WordPress? How do you edit your files?

[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]
1 Comment
  1. 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.

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer