Reputation: 191
When copying files from host machine to container where a file already exists at the destination path, the copied file is empty.
I've attempted to copy the same files to a path with a different name and this works fine.
The two lines from my dockerfile that this issue happens on are:
COPY conf/policy.xml /etc/ImageMagick-6/
COPY conf/000-default.conf /etc/apache2/sites-available/
Full dockerfile:
FROM php:7.3-apache
RUN docker-php-ext-install pdo_mysql && docker-php-ext-enable pdo_mysql
RUN docker-php-ext-install mysqli && docker-php-ext-enable mysqli
RUN apt-get update && apt-get install -y \
git libmagick++-dev \
--no-install-recommends && \
git clone https://github.com/mkoppanen/imagick.git && \
cd imagick && git checkout master && phpize && ./configure && \
make && make install && \
docker-php-ext-enable imagick && \
cd ../ && rm -rf imagick && \
apt-get install -y ghostscript && rm -r /var/lib/apt/lists/*
RUN pecl install xdebug
RUN docker-php-ext-enable xdebug
COPY conf/php.ini /etc/php/7.3/fpm/conf.d/40-custom.ini
COPY conf/policy.xml /etc/ImageMagick-6/
COPY www/ /var/www/html/
COPY conf/000-default.conf /etc/apache2/sites-available/
COPY scripts/generate-ssl.sh /generate-ssl.sh
RUN chmod +x /generate-ssl.sh
RUN /bin/bash /generate-ssl.sh
EXPOSE 80 443
Is this intended behavior ?
Upvotes: 1
Views: 2822
Reputation: 599
From Docker Documentation - Docerfile Copy:
COPY src dest
: If src is any kind of file, it is copied individually along with its metadata. In this case, if ends with a trailing slash /, it will be considered a directory and the contents of will be written at /base().
For your case try and specifiy the dest file:
COPY conf/policy.xml /etc/ImageMagick-6/policy.xml
COPY conf/000-default.conf /etc/apache2/sites-available/000-default.conf
Otherwise i dont see anything wrong with your dockerfile
Upvotes: 2