Why Digital Marketing Alone Won’t Build Your Brand ? - Sharing My Opinion - Marketing - SitePoint Forums Why Digital Marketing Alone Won’t Build Your Brand ? - Sharing My Opinion - Marketing - SitePoint Forums

Docker local setup for WordPress keeps failing (Windows 11) – CMS & WordPress – SitePoint Forums


I have been struggling for literally 12 hours+ over the last two weeks with trying to get Docker to work as a local environment for developing a WordPress theme. I’ve gone through tutorial after tutorial but even copying the code EXACTLY from tutorials, I keep getting errors.

Where I seem to be having the problem is that I can get a setup working where it installs WordPress but doesn’t mount a volume to hold my local files, but the minute I try to add that, everything fails.

I am running Docker Desktop on a Windows 11 machine.

I’ve tried too many things to collect them all here, but these two summarize the key problem I’m having.

1) Using Code from WordPress Developer Resources

I’ve copied the code EXACTLY from https://developer.wordpress.com/2022/11/14/seetup-local-development-environment-for-wordpress/. I saved the file as a docker-compose.yml file, went to that directory from PowerShell and ran docker-compose up.

This one just straight up fails to launch at all. The Docker terminal produces a lengthy series of input/output errors but the first one appears to be: WordPress not found in /var/www/html.

For reference, the copied code is as follows:

version: "3.6"
services:
 wordpress:
   image: wordpress:latest
   container_name: wordpress
   volumes:
     - ./wordpress:/var/www/html
   environment:
     - WORDPRESS_DB_NAME=wordpress
     - WORDPRESS_TABLE_PREFIX=wp_
     - WORDPRESS_DB_HOST=db
     - WORDPRESS_DB_USER=root
     - WORDPRESS_DB_PASSWORD=password
   depends_on:
     - db
     - phpmyadmin
   restart: always
   ports:
     - 8080:80
 
 db:
   image: mariadb:latest
   container_name: db
   volumes:
     - db_data:/var/lib/mysql
   environment:
     - MYSQL_ROOT_PASSWORD=password
     - MYSQL_USER=root
     - MYSQL_PASSWORD=password
     - MYSQL_DATABASE=wordpress
   restart: always
 
 phpmyadmin:
   depends_on:
     - db
   image: phpmyadmin/phpmyadmin:latest
   container_name: phpmyadmin
   restart: always
   ports:
     - 8180:80
   environment:
     PMA_HOST: db
     MYSQL_ROOT_PASSWORD: password
 
volumes:
 db_data:

2) Using Code From the WordPress Image on Docker Hub

Again, copying code exactly from the official WordPress image on https://hub.docker.com/_/wordpress. This one does allow me to install WordPress but doesn’t create a directory for me to work with locally.

For reference, the copied code is:

version: '3.1'

services:

  wordpress:
    image: wordpress
    restart: always
    ports:
      - 8080:80
    environment:
      WORDPRESS_DB_HOST: db
      WORDPRESS_DB_USER: exampleuser
      WORDPRESS_DB_PASSWORD: examplepass
      WORDPRESS_DB_NAME: exampledb
    volumes:
      - wordpress:/var/www/html

  db:
    image: mysql:5.7
    restart: always
    environment:
      MYSQL_DATABASE: exampledb
      MYSQL_USER: exampleuser
      MYSQL_PASSWORD: examplepass
      MYSQL_RANDOM_ROOT_PASSWORD: '1'
    volumes:
      - db:/var/lib/mysql

volumes:
  wordpress:
  db:

I will frankly admit that despite reading dozens of tutorials there’s a lot I don’t really ‘get’ about Docker. But that said, if I understand correctly, the volumes command has to do with mounting folders.

It seems like the major difference between the two files in #1 and 2 is this:

In #1, the WordPress service includes a direction for mounting a volume like this: - ./wordpress:/var/www/html. It also doesn’t list a volume named WordPress at the bottom of the page.

Sure enough, if I take the working code from #2 and make those two changes to it, I get another long series if input/output errors, although this one starts with:

WordPress not found in /var/www/html - copying now...
find: '.': Cannot allocate memory

I did do a search on that second error, but it seems to start running into people talking about kernels and memory management and I’m not entirely sure how to fix it.

I would really appreciate any help here! I know I may just be doing something stupid but it’s bewildering to copy code from reputable sources directly and have them fail like this.