I have a Dockerfile:
FROM php:7.4-cli
VOLUME ./result/ /usr/src/result
COPY . /usr/src/myapp
WORKDIR /usr/src/myapp
ADD https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions /usr/local/bin/
RUN chmod +x /usr/local/bin/install-php-extensions && \
install-php-extensions gd xdebug zip
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer;
RUN composer require phpoffice/phpspreadsheet
CMD [ "php", "./demo.php" ]
When demo.php executes it creates a file, I would like to copy that file to the volume on the host. Is it possible to get file back out of the container onto the host using volumes like this?
VOLUME; instead, you've told Docker to create two different anonymous volumes.VOLUMEisn't required for this case and you can delete it entirely. When you run the container you need to specify thedocker run -voption.