如何使用带有docker compose的php 7.2作曲家

I'm trying to create a simple dev env for a web symfony app with docker compose. My problem is when trying to execute composer install I get this error:

- doctrine/collections v1.5.0 requires php ^7.1 -> your PHP version (7.0.7) does not satisfy that requirement.

Here's the Composer part of my docker compose file:

composer:
        restart: 'no'
        image: composer/composer:php7
        command: install
        volumes:
           - .:/app

So that install a php 7.0 and I need at least 7.1. I tried with composer/composer:php7.1 but didn't work.

Any idea on how to do this?

Thanks in advance

composer/composer image has been deprecated and moved to the official composer Docker Container. So you can replace:

image: composer/composer:php7

with:

image: "composer"

Take the time to check the Dockerfile so you can see that php:7-alpine is used and then if you check its Dockerfile you'll see PHP_VERSION 7.2.1.

you can create your custom DOCKERFILE and build an image with php7.1

You can use --ignore-platform-reqs option

This option will ignore php, hhvm, lib-* and ext-* requirements and force the installation even if the local machine does not fulfill these.

Please refer to doc https://getcomposer.org/doc/03-cli.md