Composer installing packages for newer version

i have a problem with updating php in composer. When I change php version in require composer updates packages to version higher that I specified and get syntax error.

I am updating php from 7.4 to 8.0, the steps i made were:

I change php require to this (i have tried "^8.0.0" and "~8.0.0" too)

"require": {
    "php": "8.0.*",
    ...

then I change Dockerfile to pull from newer image FROM php:8.0-apache (i have checked php version inside the container and it is PHP 8.0.27 (cli))

next I run docker-compose exec -T app composer update --prefer-dist --ignore-platform-reqs

then new lock file is generated and there is for example this which was installed as dependency of another package, i dont have it as my require

{
    "name": "monolog/monolog",
    "version": "3.2.0",
    ...
    "require": {
        "php": ">=8.1",
        ...
    },

when i check the package which has monolog as dependency there is this "monolog/monolog": "^1.17||^2.0||^3.0", so older version was available but newer was picked and installed even when it does not meet the requirements.
Can someone help and tell me what am I doing wrong please?