No route found for “GET /user” on Symfony 5 in docker container

To create a web-service, I create a new project with a container php-nginx for web-server, postgresql-13 for db, so I create my Dockerfile based on FROM php:7.4-fpm-alpine for php-nging container and docker-compose.yml for my developments.
Previously to run container, I create symfony squeleton in my local (host under Ubuntu Bionic) folder and run make:entity user and make:crud User to have basic views.

After run containers, I try to open url localhost:8000/user and it returns :
No route found for "GET /user"

I check on my local (host) with php bin/console debug:router, it returns :

user_index                 GET        ANY      ANY    /user/                             
user_new                   GET|POST   ANY      ANY    /user/new                          
user_show                  GET        ANY      ANY    /user/{id}

routes seems ok
but if I do the same in the container, no route for user.

The question is why routes is OK in host and not in the docker container ?


So I connect to the container docker exec -it my-web-container sh,
then test to create a new entity… php bin/console make:entity test and look routes in src/Controller

Annotations are different :

 * @Route("/test")
class TestController extends AbstractController

and for user :

class UserController extends AbstractController

and the reason is that even if I use Ubuntu bionic with default PHP 7.2, I recently update to PHP 7.4 (using ppa:ondrej/php) support… and it update to PHP-8 ! and when I make:entity from the host, it use new PHP 8 annotation instead of Doctrine annotation, look at for more details.

Solution 1 : switch my container to PHP 8

update my container by change to FROM php:8-fpm-alpine

Solution 2 : stay with Doctrine annotations

but it require to make:entity inside the container… or do write it manually… but perhaps there are a config to define we want to stay to doctrine annotations?