简体   繁体   中英

Unable to install dependencies with composer inside Docker image

I was trying to install attendize by using docker.

when I put this command :

$ docker run --rm -v $(pwd):/app composer/composer install

then I got this error messages.

Loading composer repositories with package information
Installing dependencies (including require-dev) from lock file
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - symfony/class-loader v3.4.8 requires php ^5.5.9|>=7.0.8 -> your PHP version (7.0.7) does not satisfy that requirement.
    - symfony/class-loader v3.4.8 requires php ^5.5.9|>=7.0.8 -> your PHP version (7.0.7) does not satisfy that requirement.
    - Installation request for symfony/class-loader v3.4.8 -> satisfiable by symfony/class-loader[v3.4.8].

This is my composer.json :

{
    "name":"attendize/attendize",
    "description":"A free and open-source event management and ticket selling application.",
    "keywords":[
        "event management",
        "ticket selling",
        "tickets",
        "events"
    ],
    "license":"Attribution Assurance License",
    "type":"project",
    "homepage":"https://www.attendize.com",
    "require":{
        "laravel/framework":"5.2.*",
        "laravelcollective/html":"~5.0",
        "milon/barcode":"dev-master",
        "iron-io/iron_mq":"2.*",
        "intervention/image":"dev-master",
        "nitmedia/wkhtml2pdf":"dev-master",
        "maatwebsite/excel":"~2.0.0",
        "dompdf/dompdf":"dev-master",
        "laravel/socialite":"~2.0",
        "filp/whoops":"~1.0",
        "vinelab/http":"dev-master",
        "mews/purifier":"~2.0",
        "league/flysystem-aws-s3-v3":"~1.0",
        "maxhoffmann/parsedown-laravel":"dev-master",
        "omnipay/common":"~2.3",
        "omnipay/stripe":"*",
        "omnipay/paypal":"*",
        "omnipay/bitpay":"dev-master",
        "omnipay/coinbase":"dev-master",
        "laracasts/utilities":"^2.1",
        "predis/predis":"~1.0",
        "guzzlehttp/guzzle":"^6.2",
        "omnipay/migs":"^2.1",
        "mcamara/laravel-localization":"^1.2",
        "potsky/laravel-localization-helpers":"2.3.*"
    },
    "require-dev":{
        "phpunit/phpunit":"~4.0",
        "phpspec/phpspec":"~2.1",
        "fzaninotto/faker":"^1.5",
        "symfony/dom-crawler":"~3.0",
        "symfony/css-selector":"~3.0",
        "doctrine/dbal":"~2.3",
        "barryvdh/laravel-ide-helper":"^2.1"
    },
    "autoload":{
        "classmap":[
            "database",
            "app/Http/Controllers",
            "app/Models",
            "app/Attendize"
        ],
        "psr-4":{
            "App\\":"app/",
            "Attendize\\":"app/Models"
        }
    },
    "autoload-dev":{
        "classmap":[
            "tests/TestCase.php"
        ]
    },
    "scripts":{
        "post-install-cmd":[
            "php artisan clear-compiled",
            "php artisan optimize"
        ],
        "post-update-cmd":[
            "php artisan clear-compiled",
            "php artisan optimize"
        ],
        "post-create-project-cmd":[
            "php -r \"copy('.env.example', '.env');\"",
            "php artisan key:generate"
        ]
    },
    "config":{
        "preferred-install":"dist"
    },
    "extra":{
        "laravel":{
            "dont-discover":[
                "potsky/laravel-localization-helpers"
            ]
        }
    }
}

I have no idea what is the problem because I am totally new. please help me thank you.

#docker-composer.yml

version: '2'

services:
  web:
    build:
      context: .
      dockerfile: Dockerfile-nginx
    ports:
    - "8080:80"
    networks:
      - attendizenet
    volumes:
      - .:/usr/share/nginx/html/attendize
    depends_on:
      - php
  php:
    build:
      context: .
      dockerfile: Dockerfile-php
    depends_on:
      - db
      - maildev
      - redis
    volumes:
      - .:/usr/share/nginx/html/attendize
    networks: 
      - attendizenet
  php-worker:
    build:
      context: .
      dockerfile: Dockerfile-php
    depends_on:
      - db
      - maildev
      - redis
    volumes:
      - .:/usr/share/nginx/html/attendize
    command: php artisan queue:work --daemon
    networks:
      - attendizenet
  db:
    image: postgres
    environment:
      - POSTGRES_USER=attendize
      - POSTGRES_PASSWORD=attendize
      - POSTGRES_DB=attendize
    ports:
      - "5433:5432"
    volumes:
      - ./docker/pgdata:/var/lib/postgresql/data
    networks:
    - attendizenet
  maildev:
    image: djfarrelly/maildev
    ports:
      - "1080:80"
    networks:
      - attendizenet
  redis:
    image: redis
    networks:
      - attendizenet

networks:
  attendizenet:
    driver: bridge

The problem is that the PHP version provided by your Docker image, 7.0.7 , is less than what is required by one or more of your dependencies defined in composer.json .

To fix the problem, you have multiple options:

It would be helpful if you shared your Dockerfile .

Maybe it will just suffice, to drop and prune the composer/composer image and container. And then to build it again.

It seems there is more uptodate version of PHP 7.0.x available. And this alone would satisfy the platform dependency mismatch..

..or you can try running the install like this:

$ composer install --ignore-platform-reqs
  • this would ignore the mismatch and procede with the installation. Which may or may not be sufficient for development . I would not recommend ignoring the requirements at production (unless you really know what are you doing) though..

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM