Docker image two-steps build
So you can use two build stages in your Dockerfile so you don't end up having unnecessary things inside container.  Anything from first stage is gone until you move it to second stage. Something like:

FROM whatever as build-stage
WORKDIR /app
RUN apt-get update &amp;&amp; apt-get install -y unzip
RUN wget https://getcomposer.org/download/1.8.3/composer.phar
RUN php installer.php

FROM whatever as production-stage
COPY --from=build-stage /app ./