Docker ReBuild copy file from docker host

enthuguy
enthuguy used Ask the Experts™
on
Hi Docker Experts,

I have a vendor provided docker image. Which I have it in my docker registry.

I have simple Docker File which uses this image as a BASE image.

1. Would like to copy a file from the docker image to host
2. update the copied file on the host
3. Copy updated file back to docker in the same location
4. build docker with new tag

please help

Simple Dockerifle
FROM xxxxxxxx.dkr.ecr.ap-southeast-2.amazonaws.com/busybox1

RUN echo foo > bar
COPY /tmp/test.txt /tmp/test_upd.txt

Open in new window


For me even simple COPY is failing
lstat tmp/test.txt: no such file or directory
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Top Expert 2016

Commented:
 lstat tmp/test.txt: no such file or directory 

Open in new window

Nothing before the copy creates that file that i can see. The file that is created is called 'bar'

Author

Commented:
this file already exists in /tmp/test.txt
Top Expert 2016

Commented:
Not according to lstat

What is the output of
ls -l /tmp/test.txt 

Open in new window

Exploring SharePoint 2016

Explore SharePoint 2016, the web-based, collaborative platform that integrates with Microsoft Office to provide intranets, secure document management, and collaboration so you can develop your online and offline capabilities.

Author

Commented:
ls -l /tmp/test.txt
-rwxrwxr-x 1 jenkins jenkins 0 Nov 23 23:32 /tmp/test.txt

Author

Commented:
this worked

id=$(docker create xxxxxxxx.dkr.ecr.ap-southeast-2.amazonaws.com/busybox1)
docker cp $id:/file.txt /tmp/file.txt
docker cp /tmp/foo.txt $id:/foo.txt
docker cp $id:/foo.txt /tmp/new_foo.txt
docker image tag xxxxxxxx.dkr.ecr.ap-southeast-2.amazonaws.com/busybox1 xxxxxxxx.dkr.ecr.ap-southeast-2.amazonaws.com/busybox1-upd
docker rm -v $id

Author

Commented:
this worked

id=$(docker create xxxxxxxx.dkr.ecr.ap-southeast-2.amazonaws.com/busybox1)
docker cp $id:/file.txt /tmp/file.txt
docker cp /tmp/foo.txt $id:/foo.txt
docker cp $id:/foo.txt /tmp/new_foo.txt
docker image tag xxxxxxxx.dkr.ecr.ap-southeast-2.amazonaws.com/busybox1 xxxxxxxx.dkr.ecr.ap-southeast-2.amazonaws.com/busybox1-upd
docker rm -v $id
this worked

id=$(docker create xxxxxxxx.dkr.ecr.ap-southeast-2.amazonaws.com/busybox1)
docker cp $id:/file.txt /tmp/file.txt
docker cp /tmp/foo.txt $id:/foo.txt
docker cp $id:/foo.txt /tmp/new_foo.txt
docker image tag xxxxxxxx.dkr.ecr.ap-southeast-2.amazonaws.com/busybox1 xxxxxxxx.dkr.ecr.ap-southeast-2.amazonaws.com/busybox1-upd
docker rm -v $id

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial