Avatar of enthuguy
enthuguy
Flag 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
JavaDocker

Avatar of undefined
Last Comment
enthuguy

8/22/2022 - Mon
CEHJ

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

ASKER
this file already exists in /tmp/test.txt
CEHJ

Not according to lstat

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

Open in new window

All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck
enthuguy

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

ASKER
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
enthuguy

ASKER
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
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
ASKER CERTIFIED SOLUTION
enthuguy

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.