RPi-Distro / pi-gen

Tool used to create the official Raspberry Pi OS images
BSD 3-Clause "New" or "Revised" License
2.58k stars 1.61k forks source link

How to copy resources out of the docker container after build? #651

Closed benfrancis closed 1 year ago

benfrancis commented 1 year ago

Please let me know if there's a better place to ask questions like this.

Our Raspberry Pi OS derivative has a build script which call's pi-gen's build-docker.sh (with our own stage3), then extracts some files out of the working directory of the docker image after the build has completed. These files are needed for use by our over-the-air-update system.

This line in our build script used to successfully copy a directory out of the home directory of the rootfs inside the docker image:

$ docker cp "pigen_work:/pi-gen/work/${_image_name}/stage3/rootfs/home/pi/webthings/gateway" .

This no longer seems to work as the directory can not be found:

Error: No such container:path: pigen_work:/pi-gen/work/2022-11-17-Raspbian/stage3/rootfs/home/pi/webthings/gateway

Has there been a change to way this part of the build process works? Are the files now stored in a different location? Is the volume unmounted so that it's no longer accessible after the build process has completed? Note that we're currently using the buster branch of pi-gen.

I'd be grateful for any advice about how to copy files out of the working directory of the docker container after the build process has completed.

benfrancis commented 1 year ago

Could our problem possibly be related to the switch to qcow2 based images in the build process back in February 2021? https://github.com/RPi-Distro/pi-gen/pull/349

I note that with qcow2 the image is built up in layers at each stage rather than copying across the files between each stage, and maybe the file system in the working directory we were previously copying files out of is now unmounted at some point towards the end of the build?

benfrancis commented 1 year ago

Never mind, I figured out how to mount the image output by the build process and extract the files from that, instead of from the working directory which is no longer accessible.