Я хочу докернизировать свой laravel проект и выполнил настройки, но всякий раз, когда я запускаю команду php artisan migrate
, я получаю эту ошибку
SQLSTATE[HY000] [1045] Access denied for user 'admin'@'172.16.238.10' (using password: YES) (SQL: select * from information_schema.tables where table_schema = laravel and table_name = migrations and table_type = 'BASE TABLE')
Ясно, что доступ Отказано в праве администратора, но я не могу отследить, где находится ошибка.
Ниже приведен файл конфигурации:
app.dockerfile:
FROM php:7.2-apache
COPY composer.lock /var/www
COPY composer.json /var/www
WORKDIR /var/www
COPY database /var/www/database
RUN apt-get update && apt-get install -y git gnupg && \
curl -sL https://deb.nodesource.com/setup_10.x | bash - && \
apt-get install -y nodejs
RUN apt-get update && apt-get install -y \
build-essential \
libpng-dev \
libjpeg62-turbo-dev \
libfreetype6-dev \
locales \
zip \
nano \
vim \
openssl \
git \
curl\
unzip
RUN docker-php-ext-install pdo_mysql mbstring zip exif pcntl
RUN docker-php-ext-configure gd --with-gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ --with-png-dir=/usr/include/
RUN docker-php-ext-install gd
RUN php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" \
&& php composer-setup.php \
&& php -r "unlink('composer-setup.php');" \
&& php composer.phar install --no-dev --no-scripts \
&& rm composer.phar
COPY . /var/www
RUN chown -R www-data:www-data \
/var/www/storage \
/var/www/bootstrap/cache \
/var/www/public
RUN apt-get install -y libmcrypt-dev \
libmagickwand-dev --no-install-recommends \
&& pecl install mcrypt-1.0.2 \
&& docker-php-ext-install pdo_mysql \
&& docker-php-ext-enable mcrypt
COPY laravel.conf /etc/apache2/sites-available
RUN ln -s /etc/apache2/sites-available/laravel.conf /etc/apache2/sites-enabled/
RUN a2dissite 000-default.conf
RUN a2ensite laravel.conf
RUN a2enmod rewrite
RUN service apache2 restart
CMD php artisan serve --port=8000
EXPOSE 8000
docker -compose.yml:
version: '3'
services:
# The Database
database:
container_name: mysql_database
image: mysql:5.7
restart: always
volumes:
- dbdata:/var/lib/mysql
environment:
- "MYSQL_DATABASE=laravel"
- "MYSQL_USER=laravel"
- "MYSQL_PASSWORD=admin"
- "MYSQL_ROOT_PASSWORD=admin"
ports:
- 3306:3306
networks:
myapp_net:
ipv4_address: 172.16.238.11
# The Application
app:
container_name: laraveldocker
build:
context: ./
dockerfile: app.dockerfile
restart: always
volumes:
- ./storage:/var/www/storage
env_file: '.env'
environment:
- "DB_HOST=database"
- "REDIS_HOST=cache"
depends_on:
- database
ports:
- "8000:8000"
networks:
myapp_net:
ipv4_address: 172.16.238.10
# redis
cache:
image: redis:3.0-alpine
volumes:
dbdata:
networks:
myapp_net:
driver: bridge
ipam:
driver: default
config:
- subnet: 172.16.238.0/24
laravel .conf:
<VirtualHost *:80>
ServerName 172.16.238.10
ServerAdmin webmaster@localhost
DocumentRoot /var/www/public
<Directory /var/www/>
AllowOverride All
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
.env:
APP_NAME=Laravel
APP_ENV=local
APP_KEY=base64:yS7v+khzJ1GxLVAtpyWd0gG/5SOwoZr/wsXH2h/VH2o=
APP_DEBUG=true
APP_URL=http://localhost
LOG_CHANNEL=stack
DB_CONNECTION=mysql
DB_HOST=172.16.238.11
DB_PORT=3306
DB_DATABASE=laravel
DB_USERNAME=admin
DB_PASSWORD=admin
BROADCAST_DRIVER=log
CACHE_DRIVER=file
QUEUE_CONNECTION=sync
SESSION_DRIVER=file
SESSION_LIFETIME=120
REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379
AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=
AWS_DEFAULT_REGION=us-east-1
AWS_BUCKET=
PUSHER_APP_ID=
PUSHER_APP_KEY=
PUSHER_APP_SECRET=
PUSHER_APP_CLUSTER=mt1
MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"
Есть ли что-то, что я делаю не так