php mysql docker exception ssl



我正在尝试将当前使用Symfony2在Docker容器中使用的网站转移。制作部署脚本的开发者已经从公司中消失了,我从未使用php。

构建图像时,我正在运行与他们用来部署相同的命令。

php5 -d memory_limit=-1 composer.phar self-update && php5 -d memory_limit=-1  composer.phar install --prefer-dist --no-interaction

但是,当它在每个部署时都可以工作时,它都会使建筑物失败。

  • 我已经检查了我的Docker映像是否获得了互联网。它做到了。

  • 我已经从我们的生产服务中复制了配置文件和SSL。

  • 安装的包装是:NodeJS php5-CLI curl php5-curl php5-mcrypt php5-intl php5-intl php5-gd mcrypt NPM

  • 我使用php-docker的工具安装pdo_mysql:docker-php- ext-install pdo pdo pdo pdo pdo pdo_mysql

构建时的错误。

PHP Warning:  PDO::__construct(): Cannot connect to MySQL by using SSL in /app/jolicone/app/cache/dev/appDevDebugProjectContainer.php on line 3863
PHP Warning:  PDO::__construct(): [2002]  (trying to connect via tcp://cleardb.com:port-cleardb) in /app/jolicone/app/cache/dev/appDevDebugProjectContainer.php on line 3863
  [PDOException]
  SQLSTATE[HY000] [2002]
Script SensioBundleDistributionBundleComposerScriptHandler::clearCache handling the post-update-cmd event terminated with an exception
  [RuntimeException]
  An error occurred when executing the "'cache:clear --no-warmup'" command.

install [--prefer-source] [--prefer-dist] [--dry-run] [--dev] [--no-dev] [--no-custom-installers] [--no-autoloader] [--no-scripts] [--no-progress] [-v|vv|vvv|--verbose] [-o|--optimize-autoloader] [-a|--classmap-authoritative] [--ignore-platform-reqs] [--] [<packages>]...
The command '/bin/sh -c cd /app/jolicone && php5 -d memory_limit=-1 composer.phar self-update && php5 -d memory_limit=-1  composer.phar install --prefer-dist --no-interaction' returned a non-zero code: 1

有人知道那可能会从哪里来到弗罗姆吗?我已经尝试安装另一个软件包php5-mysqlnd,但这也不起作用。

如果您想关注Dockerfile

FROM php:5.6-apache
RUN apt-get update && apt-get upgrade -y && apt-get install -y apt-utils nodejs php5-cli curl php5-curl php5-mcrypt php5-intl php5-gd mcrypt npm php5-gd php5-common php5-mysqlnd
RUN docker-php-ext-install pdo pdo_mysql

# Linking nodejs binary to node alias
RUN ln -s /usr/bin/nodejs /usr/sbin/node

# Telling php about mcrypt extension
RUN sed -i '/memory_limit/cmemory_limit = -1' /etc/php5/cli/php.ini
RUN php5enmod gd mcrypt mysql pdo_mysql
COPY apache2/php.ini /usr/local/etc/php/
# Local Repository
RUN mkdir /app/
COPY jolicone/ /app/jolicone
############# Installing Composer #################
RUN cd /app/jolicone/ && php5 -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
RUN cd /app/jolicone && php5 composer-setup.php
RUN cd /app/jolicone && php5 -r "unlink('composer-setup.php');"
# Copy Apache2 Configuration
COPY apache2/sites-enabled /etc/apache2/sites-enabled/
COPY apache2/file.pem apache2/file.crt apache2/file.key /etc/apache2/
COPY apache2/ssl /etc/apache2/ssl
RUN a2enmod rewrite headers && service apache2 restart
#Copy composer.json
RUN rm -f /app/jolicone/composer.json
COPY app/composer.json /app/jolicone/
# Copy config.yml
RUN rm -f /app/jolicone/app/config/config.yml
COPY app/config.yml /app/jolicone/app/config/config.yml
# Copy parameters.yml
RUN rm -f /app/jolicone/app/config/parameters.yml
COPY app/parameters.yml /app/jolicone/app/config/parameters.yml
## mise a jour du composer.phar -> OK
RUN cd /app/jolicone && php5 -d memory_limit=-1 composer.phar self-update && php5 -d memory_limit=-1  composer.phar install --prefer-dist --no-interaction

,所以我添加了ca-certificates软件包。现在构建还可以。

但是,当我运行图像并尝试连接到网站时,我会遇到相同的错误。

vmtest:~/Docker$ cat log/*
- - [21/Jun/2016:10:29:00 +0000] "GET / HTTP/1.1" 503 261 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:47.0) Gecko/20100101 Firefox/47.0"
[Tue Jun 21 10:29:04.011586 2016] [:error] [pid 6] [client] PHP Warning:  PDO::__construct(): Cannot connect to MySQL by using SSL in /path/file.php on line 1691
[Tue Jun 21 10:29:04.011648 2016] [:error] [pid 6] [client] PHP Warning:  PDO::__construct(): [2002]  (trying to connect via tcp://db:port) in /path/file.php on line 1691
[Tue Jun 21 10:29:04.011886 2016] [:error] [pid 6] [client] PHP Fatal error:  Uncaught exception 'PDOException' with message 'SQLSTATE[HY000] [2002] ' in /path/file.php:1691nStack trace:n#0 /path/file.php(1691): PDO->__construct('mysql:host=db...', '', '', Array)n#1 /path/bootstrap.php.cache(2051): appProdProjectContainer->getPdoService()n#2 /path/file.php(1891): Symfony\Component\DependencyInjection\Container->get('pdo')n#3 /path/bootstrap.php.cache(2051): appProdProjectContainer->getSession_Handler_PdoService()n#4 /path/file.php(1903): Symfony\Component\DependencyInjection\Container->get('session.handler...')n#5 /path/bootstrap.php.cache(2051): appProdProjectContainer->getSession_Storage_NativeService()n#6 /path/file.php(1887): Symfony\Component\DependencyInjection\Container->get('session.storage...')n#7 /app/jol in /path/file.php on line 1691
vmtest:~/Docker$

相关内容

  • 没有找到相关文章

最新更新