Link to home
Start Free TrialLog in
Avatar of enthuguy
enthuguyFlag for Australia

asked on

Docker ReBuild copy file from docker host

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
Avatar of CEHJ
CEHJ
Flag of United Kingdom of Great Britain and Northern Ireland image

 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'
Avatar of enthuguy

ASKER

this file already exists in /tmp/test.txt
Not according to lstat

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

Open in new window

ls -l /tmp/test.txt
-rwxrwxr-x 1 jenkins jenkins 0 Nov 23 23:32 /tmp/test.txt
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
ASKER CERTIFIED SOLUTION
Avatar of enthuguy
enthuguy
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial