我似乎无法在Dockerfile中运行Composer安装,但是我可以在构建映像并运行容器后在容器中运行。在Dockerfile中运行时,Composer安装不会安装软件包
下面是从Dockerfile命令:
RUN composer require drupal/video_embed_field:1.5
RUN composer install --no-autoloader --no-scripts --no-progress
输出是:
Loading composer repositories with package information
Installing dependencies (including require-dev) from lock file
Nothing to install or update
但使用了搬运工,撰写容器后:
...
drupal:
image: docker_image
container_name: container
ports:
- 8081:80
volumes:
- ./container/modules:/var/www/html/web/modules
links:
# Link the DB container:
- db
运行搬运工EXEC作曲家安装将正确安装软件包:
Loading composer repositories with package information
Installing dependencies (including require-dev) from lock file
Package operations: 1 installs, 0 updates, 0 removals
...
Generating autoload files
我假定composer.json和composer.lock文件是正确的,因为我可以在容器中运行composer install命令,而无需进一步的努力,但只能在容器运行后。与
更新 试图结合作曲家命令:
RUN composer require drupal/video_embed_field:1.5 && composer install
同样的问题, “没有安装或更新”。最终,我想继续在Dockerfile中使用单独的RUN语句来利用docker缓存。
尝试只使用一个RUN,如'RUN作曲者...... &&作曲者......' – user2915097
试过了,没有运气。更新问题以包含详细信息。 –
这是因为你的'composer.lock'和'composer.json'在安装的音量上,我猜?然后,原因是在映像创建后实际发生挂载,所以在你的两条'RUN'语句之后 –