Installing Composer in Docker the 2020-s Way ############################################ :category: PHP :date: 2023-01-11 10:14:00 +0200 :tags: docker, composer While `the original way`__ is still valid, in Docker it's now easier to copy the Composer executable from its Docker image. .. __: link://slug/install-composer-in-docker .. code-block:: docker COPY --from=composer:latest /usr/bin/composer /usr/local/bin/composer or for PHP < 7.2.5 .. code-block:: docker COPY --from=composer:2.2 /usr/bin/composer /usr/local/bin/composer Please note that without the installer, dependencies won't be checked, so you also need to install git and/or zip, and preferably optional dependencies like mbstring too. Found accidentally `on the Stack Overflow`__. There is also `another interesting and underliked method`__ for the case when you don't want to keep the composer executable and cache files in your image. .. __: https://stackoverflow.com/a/58694421 .. __: https://stackoverflow.com/a/68600278