Answer the question
In order to leave comments, you need to log in
How to run yii2 migration in docker?
Configuration
version: '3'
services:
webserver:
container_name: apache-php_kfnp_yii2
build:
context: .
dockerfile: ./docker/Dockerfile
environment:
XDEBUG_CONFIG: remote_host=host.docker.internal
PHP_IDE_CONFIG: serverName=localhost
ports:
- 80:80
volumes:
- ./:/var/www
links:
- db
depends_on:
- db
db:
container_name: mysql_kfnp_yii2
image: percona:latest
command: --default-authentication-plugin=mysql_native_password
restart: on-failure
ports:
- 3306:3306
expose:
- 3306
environment:
MYSQL_ROOT_PASSWORD: password
MYSQL_DATABASE: yii2basic
MYSQL_USER: mysqluser
MYSQL_PASSWORD: mysqluser
docker-compose exec apache-php_kfnp_yii2 php yii
docker exec -it apache-php_kfnp_yii2 bash
Exception 'yii\db\Exception' with message 'SQLSTATE[HY000] [2002] No such file or directory'
in /Users/user/Sites/app/vendor/yiisoft/yii2/db/Connection.php:632
Answer the question
In order to leave comments, you need to log in
docker exec -it apache-php_kfnp_yii2 bash -c "cd /var/www && php yii mgrate"
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question