【发布时间】:2020-06-04 20:44:51
【问题描述】:
我是 docker 新手,在这里查看了多个问题,但无法找到答案。
我有一个 docker compose 文件如下:
version: "3.8"
services:
oauth_database_container:
image: mysql:5.7.30
restart: always
env_file:
- mysql.env
ports:
- 3306:3306
volumes:
- oauth_database_data_container:/var/lib/mysql
oauth_php_container:
image: php:7.3-fpm
build:
context: .
dockerfile: Dockerfile
restart: always
tty: true
ports:
- "9000:9000"
volumes:
- ./:/var/www/html
depends_on:
- oauth_database_container
oauth_nginx_container:
image: nginx:1.19.0-alpine
restart: always
tty: true
ports:
- "8000:80"
depends_on:
- oauth_database_container
- oauth_php_container
volumes:
- ./:/var/www/html
- ./docker/nginx/app.conf:/etc/nginx/conf.d/app.conf
volumes:
oauth_database_data_container:
oauth_php_data_container:
我想有我的 dockerfile
FROM php:7.3-fpm
RUN apt-get update
RUN apt-get install -y libldap2-dev libcurl4-gnutls-dev libxml2-dev zlib1g-dev libzip-dev git && \
docker-php-ext-configure ldap --with-libdir=lib/x86_64-linux-gnu
RUN docker-php-ext-install ldap mysqli curl json xml pdo_mysql zip
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
# RUN composer install --no-scripts --no-autoloader
当我进入容器并运行 compose install 这是我得到的错误。
> Illuminate\Foundation\ComposerScripts::postAutoloadDump
> @php artisan package:discover --ansi
Illuminate\Database\QueryException : SQLSTATE[42S02]: Base table or view not found: 1146 Table 'oauth.permissions' doesn't exist (SQL: select * from `permissions`)
at /var/www/html/vendor/laravel/framework/src/Illuminate/Database/Connection.php:665
661| // If an exception occurs when attempting to run a query, we'll format the error
662| // message to include the bindings with SQL, which will make this exception a
663| // lot more helpful to the developer instead of just the database's errors.
664| catch (Exception $e) {
> 665| throw new QueryException(
666| $query, $this->prepareBindings($bindings), $e
667| );
668| }
669|
Exception trace:
1 Illuminate\Foundation\Application::Illuminate\Foundation\{closure}(Object(App\Providers\AuthServiceProvider))
[internal]:0
2 Doctrine\DBAL\Driver\PDOException::("SQLSTATE[42S02]: Base table or view not found: 1146 Table 'oauth.permissions' doesn't exist")
/var/www/html/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php:63
Please use the argument -v to see more details.
Script @php artisan package:discover --ansi handling the post-autoload-dump event returned with error code 1
我可以做些什么来解决这个问题?我正在考虑运行 php artisan migrate 命令,但直到 composer 自动加载文件在那里我才能运行。所以我有点咸菜。
【问题讨论】:
-
我想说尝试使用
--no-scripts运行 composer install 这样你就可以克服这个错误,但是你在 Dockerfile 中把它注释掉了吗? -
我有它,但它仍然失败。 compose 安装有效,但是在我执行 php artisan migrate 之前我什么都做不了,但这需要自动加载,它不会与 --no-scripts 一起添加。
-
我假设两件事之一。 1)我的mysql的容器由于某种原因没有对该容器开放。但是,我可以通过主机上的 DBeaver 连接到 mysql。 2) 我的 Dockerfile 出于某种原因不在正确的上下文中。我注意到,如果这些命令不是 cmets out,它不会运行它们说 compose down 不存在。
标签: laravel docker docker-compose dockerfile