Don't get confused about Docker version.
This is an examaple of docker-compose usecase with php-fpm, nginx and composer altogether.
e.g. docker-compose -f docker-compose.run.yml up
localhost:8080
from your browser.
When dealing with composer image and composer commands, always use CMD instead of RUN.
COPY
directive is not used for
composer install
in Dockerfile, files are shared by
volumes
directive in compose file.
./code/index/
is used for nginx's root directory. Any files that are on this directory are EXPOSED to public. In the wild web world, some people are actually exposing their WHOLE APP directory by nginx(which absolutely is not recommended).