I've created a docker image of a project (very large project that takes time to compile) and I forgot to add a file in it.
I does not have to do with the build, it's just a test file.
Is it possible to add this file into my image without rebuilding everything ?
Thanks
Dockerfiles are used to build Docker images, which are then instantiated into Docker containers. Dockerfiles can contain several different instructions, one of which is COPY. The COPY instruction lets us copy a file (or files) from the host system into the image.
A Docker image contains application code, libraries, tools, dependencies and other files needed to make an application run.
Here's a full example to pull an image, add a local file to it, retag the image and push it back:
export IMAGE_URL=example.com/your_image:your_tag
docker pull $IMAGE_URL
docker create --name temp_container $IMAGE_URL
docker cp /host/path/to/file temp_container:/container/path/to/file
docker commit temp_container $IMAGE_URL
docker push $IMAGE_URL
Yes its possible, do the steps:
Do the command:
docker cp textFile.txt docker_container_name:/textFile.txt
Commit the container to build a new image with new tag version or another name;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With