使用composer安装Docker php mongodb报错

我在 Laravel 项目中使用 mongodb 和 php。当我尝试运行此命令时:


docker-compose exec php composer install

然后在控制台中出现错误并显示消息:


Failed to download mongodb/mongodb from dist: The zip extension and unzip command are both missing, skipping. Your command-line PHP is using multiple ini files. Run `php --ini` to show them.


Now trying to download from source


- Installing mongodb/mongodb (1.6.1): Cloning 4bb040c620


Cloning failed using an ssh key for authentication, enter your GitHub credentials to access private repos

Head to https://github.com/settings/tokens/new?scopes=repo&description=Composer+on+95edf1f219f1+2020-08-05+0622

to retrieve a token. It will be stored in "/root/.composer/auth.json" for future use by Composer.

Token (hidden):

这是我的所有文件:


文件:docker-compose.yml


version: '3'


services:

  nginx:

    image: nginx:stable-alpine

    container_name: nginx

    ports:

      - "${HOST_PORT}:80"

    volumes:

      - ../:/var/www/html

      - ./nginx/default.conf:/etc/nginx/conf.d/default.conf

    depends_on:

      - php

  php:

    build:

      context: .

      dockerfile: ./Dockerfile

    container_name: php

    volumes:

      - ./php/php.ini:/usr/local/etc/php/conf.d/php.ini

      - ../:/var/www/html

  mongodb:

    image: mongo:latest

    container_name: mongodb

    ports:

      - "${MONGODB_PORT}:27017"

  redis:

    image: redis:latest

    container_name: redis

    restart: always

    ports:

      - "${REDIS_PORT}:6379"

  artisan:

    build:

      context: .

      dockerfile: Dockerfile

    container_name: artisan

    volumes:

      - ../:/var/www/html

    working_dir: /var/www/html

    entrypoint: ['/var/www/html/artisan']


慕姐8265434
浏览 68回答 1
1回答

繁星淼淼

更改你的dockerfile    FROM php:7.4-fpm        ADD https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions /usr/local/bin/        RUN install-php-extensions \    pdo_mysql \    zip \    mongodb        RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
打开App,查看更多内容
随时随地看视频慕课网APP