Thursday 7 April 2022

Wordpress installation on Docker - How to access the Database

 After running through this blog on how to create a Wordpress site on Docker.  ( Which works excellently ) https://davidyeiser.com/tutorials/docker-wordpress-theme-setup


After doing so, I couldn't quite work out what details I needed to use in Sequel Pro / Sequel Ace. 



There's a line that I needed to add to the Wordpress DB setup though, and that was to add the ports .

ports:
- "3366:3306"


So my entire file looks like this. 

version: '3'

services:
db:
image: mysql:5.7
volumes:
- db_data:/var/lib/mysql
ports:
- "3366:3306"
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:
- "8000:80"
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:


And then I can use