簡體   English   中英

docker build:致命錯誤:找不到類“ Memcached”

[英]docker build : Fatal error: Class 'Memcached' not found

我正在使用symfony框架對一個項目進行docker化。 發生以下錯誤。

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"
    }
}

我的問題是,如何使運行php腳本的服務能夠“檢測” memcached服務,因為將memcached直接安裝在主機上並且對php腳本服務透明?

為Docker安裝PHP 5.6的memcached

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

並重建php容器,這將為php安裝memcache和memcached擴展

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM