As user2138149 said in a comment above, you need to use docker-compose-v2. On Ubuntu 24.04 (docker 26.1.3) I installed using:
apt install docker-compose-v2
After that, the command went through:
docker compose up