My Docker (v.2) docker-compose.yml
file has 2 Ubuntu images and 2 MariaDB images:
app:
container_name: app
image:php-apache-dev:ubuntu-16.04
links:
- mysql
depends_on:
- mysql
ports:
- '8443:443'
volumes:
- .:/app
environment:
docker: 'true'
PHP_DEBUGGER: 'xdebug'
WEB_DOCUMENT_ROOT: '/app/public'
WEB_NO_CACHE_PATTERN: '\.(.*)$$'
working_dir: '/app'
CONF_FILE: 'conf/local/develop.php'
test:
container_name: test
image:php-apache-dev:ubuntu-16.04
links:
- mysql_test
depends_on:
- mysql_test
ports:
- '8444:443'
volumes:
- .:/app
environment:
docker: 'true'
WEB_DOCUMENT_ROOT: '/app/public'
WEB_NO_CACHE_PATTERN: '\.(.*)$$'
working_dir: '/app'
CONF_FILE: 'conf/local/test.php'
mysql:
image: mariadb:latest
ports:
- '3306:3306'
environment:
MYSQL_ROOT_PASSWORD: 'dev'
MYSQL_DATABASE: 'dev'
MYSQL_USER: 'dev'
MYSQL_PASSWORD: 'dev'
mysql_test:
image: mariadb:latest
ports:
- '3307:3306'
environment:
MYSQL_ROOT_PASSWORD: 'dev'
MYSQL_DATABASE: 'dev_test'
MYSQL_USER: 'dev'
MYSQL_PASSWORD: 'dev'
One is for development, one is for testing. When I access the first one (on localhost:4443
) it works. When I access the second one (on localhost:4444
) I am able to view the website, but it denies access to the user:
Access denied for user 'dev'@'%' to database 'dev_test'
My configuration for the second site is set up to access the second MySQL port/user:
'db_port' => env('DB_PORT', '3307'),
'db_name' => env('DB_NAME', 'dev_test'),
I tried the answer to this question but without success. If I docker exec bash
into the test database image, and run SHOW GRANTS FOR dev
, it says:
GRANT ALL PRIVILEGES ON `dev_test`.* TO 'dev'@'%'