我似乎無法在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'語句之後 –