Skip to content
Advertisement

Container cannot see the prebuilt vendor folder in it

My project is throwing the next error after restarting the docker container:enter image description here

Warning: require(/var/www/ /var/www/ /vendor/composer/./symfony/polyfill-php80/bootstrap.php): Failed to open stream: No such file or directory in ‘vendor/composer/autoload_real.php line 71

My Dockerfile:

JavaScript

My docker-compose:

JavaScript

Inside container run ls vendor/symfony before restarting the container: enter image description here And after:enter image description here

The error is solving if remove the vendor directory and run composer install.

I’m not a Jedi of the Docker.

Thanks for any help/suggestion!

Advertisement

Answer

In your volume section, you are mounting the host machine folder ./project to your container’s /var/www/project:

JavaScript

The vendor folder is built inside of you container by the RUN command. It’s probably still there. But when you run docker-compose up, you instructed it to mask whatever inside with your host’s ./project folder when running it. So the container don’t see anything that you built before hand.

My advice is to only mount the folder that you need to change from time to time. For example:

JavaScript

Then the container will properly use the prebuilt /vendor while storing the thing that you need to keep in host.

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement