I've got trouble using docker-compose. docker-compose picks wrong version of php.
networks:
laravel:
services:
nginx:
image: nginx:stable-alpine
container_name: nginx
ports:
- "8088:80"
volumes:
- ./src:/var/www/html
- ./nginx/default.conf:/etc/nginx/conf.d/default.conf
depends_on:
- php
- mysql
networks:
- laravel
mysql:
image: mysql:5.7.22
container_name: mysql
restart: unless-stopped
tty: true
ports:
- "4306:3306"
volumes:
- ./mysql:/var/lib/mysql
environment:
MYSQL_DATABASE: wrong
MYSQL_USER: wrong
MYSQL_PASSWORD: secret
MYSQL_ROOT_PASSWORD: secret
SERVICE_TAGS: dev
SERVICE_NAME: mysql
networks:
- laravel
php:
build:
context: .
dockerfile: Dockerfile
container_name: php
volumes:
- ./src:/var/www/html
ports:
- "9000:9000"
networks:
- laravel
composer:
image: composer:1.10.22
container_name: composer
volumes:
- ./src:/var/www/html
working_dir: /var/www/html
networks:
- laravel
docker file is
FROM php:7.3-fpm-alpine
RUN docker-php-ext-install pdo pdo_mysql
and I run these commands
docker-compose up -d --build
docker-compose run --rm composer install
and I got this message
This package requires php ^7.1.3 but your PHP version (8.0.6) does not satisfy that requirement.
I put down php7.3 in dockerfile, but php(8.0.6) installed. I don't know why.
I tried docker system prune -a, and run the commands, but still doesn't work.