How can I overwrite a file through Dockerfile in docker container?
Drop the file name from the destination:
COPY php5-cgi.conf /etc/apache2/conf-enabled/
The destination is an absolute path (not filename), or a path relative to the work directory, into which the source will be copied inside the destination container.
I just tested following docker file with no problem.
from debian:jessieCOPY debian_version /etc/debian_version
As PolarisUser stated in comments, you need to put debian_version
in the same folder as dockerfile
or use absolute path
.Another way would be mounting the file when running the container.
docker run -d -v php5-cgi.conf:/etc/apache2/conf-enabled/php5-cgi.conf --name your_container_name <imagename:tag> <startup command>
docker cp "yourfilename" "containername":/destination
Below is a working example:
docker cp config.json bigdataapp:/app/src/bigdatapp/wwwroot/assets/config/config.json