Reputation: 126
Halo, I am following this guide to create a local Wordpress Setup: https://davidyeiser.com/tutorials/docker-wordpress-theme-setup which worked quite well, but now I am trying to connect with MYSQLWorkbench and it never works.
yml file:
version: '3'
services:
db:
image: mysql:5.7
volumes:
- db_data:/var/lib/mysql
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:
- "9210: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:
my attempt to connect is as followed,
I have tried different combinations of passwords or ports like 33060, but couldn't get it to connect.
Any Idea what I am missing?
Upvotes: 0
Views: 165
Reputation: 4544
You need to expose the port 3306 of the db
container instance.
version: '3'
services:
db:
image: mysql:5.7
ports:
- "3306:3306" <-- this is the important part here!
volumes:
- db_data:/var/lib/mysql
restart: always
environment:
MYSQL_ROOT_PASSWORD: somewordpress
MYSQL_DATABASE: wordpress
MYSQL_USER: wordpress
MYSQL_PASSWORD: wordpress
...
Upvotes: 1