Add a file in a docker image

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:

  1. Mount the image and make a container
  2. Do the command:

    docker cp textFile.txt docker_container_name:/textFile.txt

  3. Commit the container to build a new image with new tag version or another name;

Tags:

Docker