Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save karlhorky/91ab5c0b2d49a022937bab11d3cf8531 to your computer and use it in GitHub Desktop.
Save karlhorky/91ab5c0b2d49a022937bab11d3cf8531 to your computer and use it in GitHub Desktop.
Setting up WordPress and MySQL on Windows 10 Home (Docker Toolbox)
  1. Set up a docker-compose.yaml file (file content at the bottom of this page).

  2. Also create a data/mysql folder in your project.

  3. In order to set up a volume for MySQL in Docker Toolbox, we will need a VirtualBox Shared Folder, just like mentioned in Fixing Volumes in Docker Toolbox.

    VirtualBox by default has a c/Users Shared Folder that we can use for this (as long as your project is within C:\Users. Verify that this shared folder is set up properly:

    Capture

  4. Add a new volume to the mydatabase service in the docker-compose.yaml for the database files. Because we are using docker-toolbox and VirtualBox, we need an absolute path, starting with //c/:

    volumes:
       - //c/Users/your_username/projects/wordpress-docker-stack/data/mysql:/var/lib/mysql

  5. If you were to start the containers now, it would create some files within the data/mysql folder, but it would quickly run into problems because of the asynchronous I/O subsystem used by InnoDB.

    It would show you an error message like Operating system error number 22 in a file operation. or Operating system error number 22 in a file operation. or File ./undo_001: 'aio write' returned OS error 122:

    tempsnip2

    Side note: Confusingly, if you were to try re-running the database after the initial files have been created but before the asynchronous issue has been resolved, it will show you an error message like --initialize specified but the data directory has files in it or The designated data directory /var/lib/mysql/ is unusable. You can remove all files that the server added to it.. The data/mysql directory needs to be empty for the first setup of MySQL:

    tempsninipp

  6. In order to disable the asynchronous I/O subsystem feature to make InnoDB work with the VirtualBox shared folder, a MySQL config file can be created, as mentioned on Issues with Docker db images on Windows 10 Home.

    First, add an additional volume:

    - //c/Users/your_username/projects/wordpress-docker-stack/data/conf:/etc/mysql/conf.d
  7. Then create the folder data/conf and add a file called local.cnf with the contents:

    [mysqld]
    innodb_use_native_aio=0
  8. Then, find this file in Windows Explorer and make it Read-only:

    Capture (1)

    The reason for this is that MySQL requires that the file is read-only. If we don't do this, it will complain with errors like [Warning] World-writable config file '/etc/mysql/conf.d/local.cnf' is ignored.:

    tempsnip

  9. Now WordPress and MySQL should run when you start the containers! 🎉

version: '3'
services:
mywordpress:
image: wordpress
environment:
WORDPRESS_DB_HOST: 'mydatabase'
WORDPRESS_DB_NAME: 'wordpress_db'
WORDPRESS_DB_USER: 'wordpress_user'
WORDPRESS_DB_PASSWORD: 'my-secret-wordpress-pw'
ports:
- 8080:80
networks:
- mynetwork
mydatabase:
image: mysql
environment:
MYSQL_ROOT_PASSWORD: 'my-secret-root-pw'
MYSQL_DATABASE: 'wordpress_db'
MYSQL_USER: 'wordpress_user'
MYSQL_PASSWORD: 'my-secret-wordpress-pw'
command: --default-authentication-plugin=mysql_native_password
networks:
- mynetwork
networks:
mynetwork:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment