Copying docker image in DIB

I am building an Image using Diskimage-Builder and I am trying to deploy a docker image inside the buillt DIB-Image.
The optimal solution is to copy the docker image from the host system as a tar file into the DIB-image and load and deploy the image in the first boot maybe as a systemd service. However, I do not have enough storage for having the image and the image tar file at the same time in my DIB-image.
The solution i came up with is to copy the docker library path of the host into the DIB-image so when the image is built, it already has this docker image inside it. This would also not work in my case because there are other images on the system that i can not delete and do not want to copy into my DIB-image.

Is there any other/better way to make this work ?
so sum up: I want a docker image built on my host system in my DIB-image but i can not use the image tar file.

I would appreciate any insights on this.

If you need Docker in the image, wouldn’t it be easier to install Docker in it and pull the required image? If the image is not available in a public registry, you could maybe runa local registry if you have enough space on the host. Alternatively, you could run docker in docker on the host, to have a second docker installation where you install the required images and you would need to copy the files from that.

I think you could also stream a tar file like this:

curl http://192.168.1.2/myfile.tar.gz | tar xz -C /destination

Haven’t tested, but I usded to do something similar using SSH.and in one case, combined with docker commands for copying volumes:

Thank you for your reply.
The problem is that the Linux image will neither have internet connection nor connection to any other devices after boot so I need to find a way to integrate the image during the DIB build pipeline.
Also, docker engine is yet started during DIB build so docker commands for handling images will also not work in that stage.

Than the only way I can see is indeed run Docker in Docker on the host, download the images, make a tar file from the docker data root and stream into the image any way possible (or mount into it if it is possible during image creation) and extract it. But this is not really a Docker question anymore since you cannot use Docker commands so your only option is copying files. Since there are special files in the Docker Data root, you need to make sure you keep all the links, all the filetypes, all the permissions/flags. I don’t know how it can be done when using DIB.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.