Search code examples
dockercomposer-phpddev

How can I update the composer version that is being used inside my ddev containers?


Currently my docker/ddev setup is running Composer version 1.10.6 2020-05-06 inside the container.

I would like to make the composer version inside the container be 1.10.7 2020-06-03.

I found one way to do it: ddev exec sudo composer self-update, but it's not permanent. The container reverts back to using 1.10.6 after a ddev restart.

In all of my searches, I can't find a way to update the documents that create the container so they update composer permanently. I don't need it to attempt to update every time I start my container, I just need to be able to tell it now to permanently change over to the version I want.

An additional piece: adding RUN sudo composer self-update to the .ddev/web-build/Dockerfile makes it attempt to update every time, which is not ideal. I want to update when I'm ready, as I also need to update my test servers to match versions.

I added that command to my Dockerfile and it updated to 1.10.7. I removed the command from my Dockerfile so that it doesn't update every time I restart ddev. When I restarted ddev (without that command in the Dockerfile) it reverted composer back to 1.10.6.

Where is it getting the instructions to use that version? I need to find that and tell it to use 1.10.7 instead. I don't want it to update itself every time I do ddev restart.


Solution

  • (This answer is dramatically outdated; the correct answer is the other answer by @Dig)

    It's not normally important, but you can add a .ddev/web-build/Dockerfile with these contents:

    ARG BASE_IMAGE
    FROM $BASE_IMAGE
    RUN composer self-update
    

    And your composer will be updated during the image build process.