I've set following settings with 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.
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. After that I start this image as container and set the handler_id
to PdoSessionHandler
, clear cache and it works. But why is the service or class PdoSessionHandler
missing during cache clear process? This only happen by build a docker image.
Dockerfile
############################################
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. However, there is no database for the docker image build process. As a result, the service can not be loaded.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.