Php docker构建:致命错误:类';Memcached';找不到

Php docker构建:致命错误:类';Memcached';找不到,php,symfony,docker,memcached,dockerfile,Php,Symfony,Docker,Memcached,Dockerfile,我正在整理一个用symfony框架制作的项目。发生以下错误 Loading composer repositories with package information Installing dependencies (including require-dev) from lock file Warning: The lock file is not up to date with the latest changes in composer.json. You may be getting

我正在整理一个用symfony框架制作的项目。发生以下错误

Loading composer repositories with package information
Installing dependencies (including require-dev) from lock file
Warning: The lock file is not up to date with the latest changes in composer.json. You may be getting outdated dependencies. Run update to update them.
Package operations: 28 installs, 0 updates, 0 removals
  - Installing twig/twig (v1.12.1): Cloning v1.12.1
    Failed to download twig/twig from source: Your configuration does not allow connections to git://github.com/fabpot/Twig.git. See https://getcomposer.org/doc/06-config.md#secure-http for details.
    Now trying to download from dist
  - Installing twig/twig (v1.12.1): Downloading (100%)         
  - Installing doctrine/common (2.3.0): Cloning 2.3.0
  - Installing symfony/symfony (v2.1.7): Cloning v2.1.7
    Failed to download symfony/symfony from source: Your configuration does not allow connections to git://github.com/symfony/symfony.git. See https://getcomposer.org/doc/06-config.md#secure-http for details.
    Now trying to download from dist
  - Installing symfony/symfony (v2.1.7): Downloading (100%)         
  - Installing jdorn/sql-formatter (v1.2.0): Cloning v1.2.0
    Failed to download jdorn/sql-formatter from source: Your configuration does not allow connections to git://github.com/jdorn/sql-formatter.git. See https://getcomposer.org/doc/06-config.md#secure-http for details.
    Now trying to download from dist
  - Installing jdorn/sql-formatter (v1.2.0): Downloading (100%)         
  - Installing doctrine/dbal (2.3.2): Cloning 2.3.2
  - Installing doctrine/doctrine-bundle (v1.1.0): Cloning v1.1.0
    Failed to download doctrine/doctrine-bundle from source: Your configuration does not allow connections to git://github.com/doctrine/DoctrineBundle.git. See https://getcomposer.org/doc/06-config.md#secure-http for details.
    Now trying to download from dist
  - Installing doctrine/doctrine-bundle (v1.1.0): Downloading (100%)         
  - Installing doctrine/orm (2.3.2): Cloning 2.3.2
    Failed to download doctrine/orm from source: Your configuration does not allow connections to git://github.com/doctrine/doctrine2.git. See https://getcomposer.org/doc/06-config.md#secure-http for details.
    Now trying to download from dist
  - Installing doctrine/orm (2.3.2): Downloading (100%)         
  - Installing friendsofsymfony/jsrouting-bundle (1.1.2): Cloning 1.1.2
  - Installing jms/cg (1.0.0): Cloning 1.0.0
    Failed to download jms/cg from source: Your configuration does not allow connections to git://github.com/schmittjoh/cg-library.git. See https://getcomposer.org/doc/06-config.md#secure-http for details.
    Now trying to download from dist
  - Installing jms/cg (1.0.0): Downloading (100%)         
  - Installing jms/metadata (1.1.1): Cloning 1.1.1
  - Installing jms/aop-bundle (1.0.0): Cloning 1.0.0
  - Installing jms/di-extra-bundle (1.1.1): Cloning 1.1.1
  - Installing jms/security-extra-bundle (1.2.0): Cloning 1.2.0
  - Installing kriswallsmith/assetic (dev-master 5591252): Cloning 5591252faa
    Failed to download kriswallsmith/assetic from source: Your configuration does not allow connections to http://github.com/kriswallsmith/assetic.git. See https://getcomposer.org/doc/06-config.md#secure-http for details.
    Now trying to download from dist
  - Installing kriswallsmith/assetic (dev-master 5591252): Downloading (100%)         
  - Installing phpoffice/phpexcel (1.7.9): Cloning 7a7634fba6
  - Installing irongit/symfony2-stream-response (dev-master 3e5082e): Cloning 3e5082e7be
  - Installing liuggio/excelbundle (v1.0.5): Cloning 9cf3e2ec21
  - Installing kriswallsmith/buzz (v0.10): Cloning 759432d663
  - Installing sensio/buzz-bundle (dev-master 929c883): Cloning 929c883f8d
  - Installing sensio/distribution-bundle (v2.1.7): Cloning v2.1.7
  - Installing sensio/framework-extra-bundle (v2.1.7): Cloning v2.1.7
  - Installing sensio/generator-bundle (v2.1.7): Cloning v2.1.7
  - Installing symfony/assetic-bundle (v2.1.0): Cloning v2.1.0-RC2
  - Installing monolog/monolog (1.2.1): Cloning 1.2.1
  - Installing symfony/monolog-bundle (v2.1.7): Cloning v2.1.7
  - Installing swiftmailer/swiftmailer (v4.2.2): Cloning v4.2.2
    Failed to download swiftmailer/swiftmailer from source: Your configuration does not allow connections to git://github.com/swiftmailer/swiftmailer.git. See https://getcomposer.org/doc/06-config.md#secure-http for details.
    Now trying to download from dist
  - Installing swiftmailer/swiftmailer (v4.2.2): Downloading (100%)         
  - Installing symfony/swiftmailer-bundle (v2.1.7): Cloning v2.1.7
  - Installing twig/extensions (dev-master 5c2d515): Cloning 5c2d515d46
kriswallsmith/assetic suggests installing leafo/lessphp (Assetic provides the integration with the lessphp LESS compiler)
kriswallsmith/assetic suggests installing leafo/scssphp (Assetic provides the integration with the scssphp SCSS compiler)
kriswallsmith/assetic suggests installing leafo/scssphp-compass (Assetic provides the integration with the SCSS compass plugin)
kriswallsmith/assetic suggests installing ptachoire/cssembed (Assetic provides the integration with phpcssembed to embed data uris)
monolog/monolog suggests installing ext-amqp (Allow sending log messages to an AMQP server (1.0+ required))
monolog/monolog suggests installing ext-mongo (Allow sending log messages to a MongoDB server)
monolog/monolog suggests installing mlehner/gelf-php (Allow sending log messages to a GrayLog2 server)
Generating autoload files
> Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::buildBootstrap
> Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::installAssets

Fatal error: Class 'Memcached' not found in /var/www/html/gallery_core/app/cache/dev/appDevDebugProjectContainer.php on line 497
Script Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::installAssets handling the post-install-cmd event terminated with an exception


  [RuntimeException]                                                            
  An error occurred when executing the "'assets:install '\''web'\'''" command. 
我搜索了一段时间,发现这可能是memcached中没有正确安装。但在这里,我使用docker构建了一个memcached服务

Memcached dockerfile:

FROM memcached:1.4-alpine

# Port to expose (default: 11211)
EXPOSE 11211

# Default Memcached run command arguments
CMD ["-m", "128"]

# Set the user to run Memcached daemon
USER daemon

# Set the entrypoint to memcached binary
ENTRYPOINT memcached
php Dockerfile

FROM php:5.6-apache

RUN apt-get update && apt-get install -y \
    git \
    unzip

# Install Composer
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
RUN composer --version


ENV TZ=America/Los_Angeles
ENV SYMFONY_ENV='dev'
# RUN php composer.phar install --prefer-source

ENV docroot='/var/www/html'
ENV contentroot='/var/content'     


RUN mkdir $docroot/gallery_core
copy . $docroot/gallery_core/
copy php.ini /usr/local/etc/php

RUN cd $docroot/gallery_core

WORKDIR $docroot/gallery_core


RUN composer install --prefer-source

RUN cp $docroot/gallery_core/web/app_dev.php $docroot/gallery_core/web/app.php 

# install symfony symlinks
RUN php $docroot/gallery_core/app/console assets:install $docroot/gallery_core/web --symlink

# install a symlink for the assets:
RUN ln -s $docroot/gallery_core/web $docroot/gallery_core/web/gcassets
Composer.json

{
    "name": "symfony/framework-standard-edition",
    "description": "The \"Symfony Standard Edition\" distribution",
    "autoload": {
        "psr-0": { "": "src/" }
    },
    "require": {
        "php": ">=5.3.3",
        "symfony/symfony": "2.1.*",
        "doctrine/orm": ">=2.2.3,<2.4-dev",
        "doctrine/doctrine-bundle": "1.1.*",
        "twig/extensions": "1.0.*@dev",
        "symfony/assetic-bundle": "2.1.*",
        "symfony/swiftmailer-bundle": "2.1.*",
        "symfony/monolog-bundle": "2.1.*",
        "sensio/distribution-bundle": "2.1.*",
        "sensio/framework-extra-bundle": "2.1.*",
        "sensio/generator-bundle": "2.1.*",
        "jms/security-extra-bundle": "1.2.*",
        "jms/di-extra-bundle": "1.1.*",
        "kriswallsmith/assetic": "1.1.*@dev",
        "friendsofsymfony/jsrouting-bundle": "1.1.*",
        "irongit/symfony2-stream-response": "dev-master",
        "liuggio/excelbundle": ">=1.0.4",
        "sensio/buzz-bundle": "dev-master"
    },
    "scripts": {
        "post-install-cmd": [
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installRequirementsFile"
        ],
        "post-update-cmd": [
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installRequirementsFile"
        ]
    },
    "extra": {
        "symfony-app-dir": "app",
        "symfony-web-dir": "web"
    }
}
{
“名称”:“symfony/framework标准版”,
“说明”:“Symfony标准版”发行版,
“自动加载”:{
“psr-0”:{”“:“src/”}
},
“要求”:{
“php”:“>=5.3.3”,
“symfony/symfony”:“2.1.*”,
“条令/orm”:“>=2.2.3,=1.0.4”,
“sensio/buzz捆绑包”:“开发主机”
},
“脚本”:{
“安装后命令”:[
“Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap”,
“Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets”,
“Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installRequirementsFile”
],
“更新后命令”:[
“Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap”,
“Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache”,
“Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets”,
“Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installRequirementsFile”
]
},
“额外”:{
“symfony应用程序目录”:“应用程序”,
“symfony网络目录”:“网络”
}
}

我的问题是如何使运行php脚本的服务能够“检测”memcached服务,因为memcached是直接安装在主机上的,并且对php脚本服务是透明的?

要为docker(php-5.6)更改安装memcached


重建php容器,这将为php安装memcache和memcached扩展

问题不在memcached本身。问题是您的php没有memcached php模块,包通常是
php5 memcached
请发布php fpm serviceHi@Matteo的docker文件,我已经发布了php docker文件,请您看一下。您好,更改后仍然失败:找不到有效的包安装失败错误:服务“php”未能生成:命令“/bin/sh-c apt get update&&apt get install-y git unzip zlib1g dev libmemcached11 libmemcached dev&&yes”| pecl install memcached&&docker php ext enable memcached&&yes”| pecl installmemcache&&docker php ext enable memcache'返回一个非零代码:1
memcached-2.2.0
。。。还有更多change@frank(没问题)
RUN apt-get update && apt-get install -y \
    git \
    unzip
RUN apt-get update \
    && apt-get install -y git unzip zlib1g-dev libmemcached11 libmemcached-dev \
    && yes '' | pecl install memcached-2.2.0 \
    && docker-php-ext-enable memcached \
    && yes '' | pecl install memcache \
    && docker-php-ext-enable memcache