Пытаюсь получить доступ к MySql установленном внутри Docker контейнера Выдается ошибка Access denied for user 'root'@'172.18.0.5' (using password: YES) Здесь мой docker-compose.yml file:
version: '2'
services:
# The Application
app:
image: app
working_dir: /var/www
volumes:
- /var/www/storage
env_file: '.env'
environment:
- "DB_HOST=database"
- "REDIS_HOST=cache"
# The Web Server
web:
image: web
ports:
- "8000:80"
# The Database
database:
image: mysql:5.7.19
volumes:
- dbdata:/var/lib/mysql
environment:
- MYSQL_DATABASE="dev"
- MYSQL_USER="root"
- MYSQL_PASSWORD="root"
- MYSQL_ROOT_PASSWORD="root"
ports:
- "3306:3306"
# redis
cache:
image: redis:3.0-alpine
volumes:
dbdata:
собираю и запускаю все командами:
docker build -t app -f app.dockerfile .
build -t web -f web.dockerfile .
docker-compose -f docker-compose.yml up -d
$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
819c5b90e1e1 mysql:5.7.19 "docker-entrypoint..." 20 seconds ago Up 19 seconds 0.0.0.0:3306->3306/tcp webapp_database_1
331c9b71701b app "docker-php-entryp..." 21 seconds ago Up 21 seconds 9000/tcp webapp_app_1
a634f718dfc6 web "nginx -g 'daemon ..." 12 days ago Up 21 hours 443/tcp, 0.0.0.0:8000->80/tcp webapp_web_1
6fa2801c08fd redis:3.0-alpine "docker-entrypoint..." 2 weeks ago Up 21 hours 6379/tcp webapp_cache_1
$ docker port webapp_database_1 3306/tcp
0.0.0.0:3306
$ docker-machine ip
192.168.99.100
mysql -h 192.168.99.100 -P 3306 -u root -p
Enter password: ****
ERROR 1045 (28000): Access denied for user 'root'@'192.168.99.1' (using password: YES)
$ docker exec -it 819c5b90e1e1 /bin/bash
root@819c5b90e1e1:/# mysql -u root -p
Enter password:
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
Может неправильно написан .env файл?
APP_NAME=WEBAPP
APP_ENV=192.168.99.100
APP_KEY=base64:eKcu6C/Xg6Kok+sd6zJMc17WRucHh8tE1BZYnjfcV+c=
APP_DEBUG=true
APP_LOG_LEVEL=debug
APP_URL=192.168.99.100
DB_CONNECTION=mysql
DB_HOST=192.168.99.100
DB_PORT=3306
DB_DATABASE=dev
DB_USERNAME=root
DB_PASSWORD=root