[英]Docker build: Symfony 4 class PdoSessionHandler does not exist
I've set following settings with Symfony 4: https://symfony.com/doc/current/doctrine/pdo_session_storage.html 我已经使用Symfony 4设置了以下设置: https : //symfony.com/doc/current/doctrine/pdo_session_storage.html
If the docker image will build output this error, no matter how the pdo session handler is configured. 如果docker image将生成输出此错误,则无论pdo会话处理程序如何配置。
Generating autoload files
ocramius/package-versions: Generating version class...
ocramius/package-versions: ...done generating version class
Executing script cache:clear [KO]
[KO]
Script cache:clear returned with error code 1
!!
!! In DefinitionErrorExceptionPass.php line 54:
!!
!! Invalid service "Symfony\Component\HttpFoundation\Session\Storage\Handler\P
!! doSessionHandler": class "Symfony\Component\HttpFoundation\Session\Storage\
!! Handler\PdoSessionHandler" does not exist.
!!
!!
!!
If I set handler_id
as file like here: https://symfony.com/doc/current/session.html The Docker Image will be build without problems. 如果我将
handler_id
设置为如下所示的文件: https ://symfony.com/doc/current/session.html Docker镜像将被构建而不会出现问题。 After that I start this image as container and set the handler_id
to PdoSessionHandler
, clear cache and it works. 之后,我将此图像作为容器启动,并将
handler_id
设置为PdoSessionHandler
,清除缓存即可使用。 But why is the service or class PdoSessionHandler
missing during cache clear process? 但是,为什么在清除缓存过程中缺少服务或类
PdoSessionHandler
? This only happen by build a docker image. 这仅通过构建docker映像来发生。
Dockerfile Docker文件
############################################
FROM alpine:3.8 as build-api
############################################
ENV APP_ENV prod
RUN apk update \
&& apk upgrade \
&& apk add \
composer \
git \
openssh-client \
php7-apcu \
php7-bcmath \
php7-ctype \
php7-curl \
php7-dev \
php7-dom \
php7-fileinfo \
php7-fpm \
php7-gd \
php7-imagick \
php7-imap \
php7-intl \
php7-mbstring \
php7-pdo_pgsql \
php7-pgsql \
php7-simplexml \
php7-soap \
php7-tokenizer \
php7-xml \
php7-zip \
php7-zmq
RUN echo 'memory_limit = 2G' >> /etc/php7/php.ini
COPY app /app
COPY --from=build-ssh /ssh /root/.ssh
WORKDIR /app
RUN composer --no-interaction install
############################################
FROM alpine:3.8 as env-app
############################################
ENV APP_ENV prod
RUN apk update \
&& apk upgrade \
&& apk add \
ghostscript \
nginx \
pdftk \
php7-apcu \
php7-bcmath \
php7-ctype \
php7-curl \
php7-dev \
php7-dom \
php7-fileinfo \
php7-fpm \
php7-gd \
php7-iconv \
php7-imagick \
php7-imap \
php7-intl \
php7-json \
php7-mailparse \
php7-mbstring \
php7-pdo_pgsql \
php7-simplexml \
php7-session \
php7-soap \
php7-tokenizer \
php7-xml \
php7-xmlreader \
php7-xmlwriter \
php7-zip \
php7-zmq \
qpdf \
tzdata
RUN cp /usr/share/zoneinfo/Europe/Berlin /etc/localtime
RUN apk add nginx \
&& adduser -D -g 'www' www \
&& chown -R www:www /var/lib/nginx \
&& mkdir -p /run/nginx
RUN apk add php7-fpm \
&& mkdir -p /run/php
COPY --chown=www:www --from=build-api /app /app
RUN chown -R www:www /app \
&& chmod -R 500 /app \
&& chmod -R 700 /app/var
WORKDIR /app
CMD php-fpm7 && nginx -g "daemon off;"
EXPOSE 80
If the PdoSessionHandler
is registered in the session config under handler_id
, the cache clear will establish a connection to the database. 如果
PdoSessionHandler
在session config中的handler_id
下注册,则清除缓存将建立与数据库的连接。 However, there is no database for the docker image build process. 但是,没有用于Docker映像构建过程的数据库。 As a result, the service can not be loaded.
结果,该服务无法加载。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.