Installing a docker image in rootfs during rootfs creation

Hi

I’m working on creating a script that builds Tegra 36.3, creates the rootfs, and installs some application software that we have created. The result from this is the system.img file that shall be used to flash the units during production.

However I have some problems installing a docker image into the tegra rootfs.

I’m using the chroot to copy some files into the Tegra 36.3 rootfs. However, I would like to install an docker image on to the rootfs. But the docker engine is not running, so running “docker load” does not work.

Does anyone have a suggestion to how a docker image can be installed into the rootfs during installation?

Hi,

Could you share more info about “install a docker image”?
Do you mean you want to pull an image into the rootfs so after the flashing, the image is there by default?

If yes, it should work.
Please share the error or related log you meet with us for further suggestions.

Thanks.

Hi, and thanks for helping me :)

Certainly.
Yes I would like to pull an image into the rootfs so that it is there by default :)
I have made this function that I’m running in order to install images inside the image:

function addDockerImage
{
	echo "Function addDockerImage()"
    if [ $# -lt 1 ]; then
        echo "Need at least 1 arguments"
        exit 1
    fi

    container_name="$1"

    echo "Loading ${container_name}."
    pushd "${ROOTFS_DIR}" > /dev/null 2>&1
    cp "/usr/bin/qemu-aarch64-static" "usr/bin/"
    chmod 755 "usr/bin/qemu-aarch64-static"
    mount /sys ./sys -o bind
    mount /proc ./proc -o bind
    mount /dev ./dev -o bind
	mkdir ./apps
	mount $APP_DIR ./apps -o bind

	LC_ALL=C chroot . ls # Print the content of the root in chroot env
	LC_ALL=C chroot . dockerd # Trying to start dockerd
	LC_ALL=C chroot . docker load --input /apps/$container_name # Trying to load the dockerimage that I want to install
	
	
	mount | grep -q "${ROOTFS_DIR}/apps" && umount ./apps
	cleanup;

	popd > /dev/null

}

This results in this output:

Function addDockerImage()

Loading image_0_1.tar.

apps  bin  boot  dev  etc  home  lib  media  mnt  opt  proc  root  run  sbin  srv  sys  tmp  usr  var
INFO[2024-06-26T07:20:03.599387288Z] Starting up                                  
WARN[2024-06-26T07:20:03.607635251Z] Error while setting daemon root propagation, this is not generally critical but may cause some functionality to not work or fallback to less desirable behavior  dir=/var/lib/docker error="error getting daemon root's parent mount: Can't find mount point of /var/lib/docker"
INFO[2024-06-26T07:20:03.612437672Z] containerd not running, starting managed containerd 
INFO[2024-06-26T07:20:03.624149170Z] started new containerd process                address=/var/run/docker/containerd/containerd.sock module=libcontainerd pid=34678
ERRO[2024-06-26T07:20:03.625758139Z] failure getting variant                       error="getCPUInfo for pattern: Cpu architecture: not found"
INFO[2024-06-26T07:20:03.965700787Z] starting containerd                           revision= version=1.7.2
INFO[2024-06-26T07:20:04.053378190Z] loading plugin "io.containerd.snapshotter.v1.aufs"...  type=io.containerd.snapshotter.v1
INFO[2024-06-26T07:20:04.086192087Z] skip loading plugin "io.containerd.snapshotter.v1.aufs"...  error="aufs is not supported (modprobe aufs failed: exit status 1 \"modprobe: FATAL: Module aufs not found in directory /lib/modules/6.5.0-35-generic\\n\"): skip plugin" type=io.containerd.snapshotter.v1
INFO[2024-06-26T07:20:04.086789540Z] loading plugin "io.containerd.snapshotter.v1.btrfs"...  type=io.containerd.snapshotter.v1
WARN[2024-06-26T07:20:04.087578915Z] failed to load plugin io.containerd.snapshotter.v1.btrfs  error="failed to find the mount info for \"/var/lib/docker/containerd/daemon/io.containerd.snapshotter.v1.btrfs\""
INFO[2024-06-26T07:20:04.087681488Z] loading plugin "io.containerd.content.v1.content"...  type=io.containerd.content.v1
INFO[2024-06-26T07:20:04.088086310Z] loading plugin "io.containerd.snapshotter.v1.native"...  type=io.containerd.snapshotter.v1
INFO[2024-06-26T07:20:04.088441273Z] loading plugin "io.containerd.snapshotter.v1.overlayfs"...  type=io.containerd.snapshotter.v1
INFO[2024-06-26T07:20:04.091396616Z] loading plugin "io.containerd.snapshotter.v1.devmapper"...  type=io.containerd.snapshotter.v1
WARN[2024-06-26T07:20:04.091598376Z] failed to load plugin io.containerd.snapshotter.v1.devmapper  error="devmapper not configured"
INFO[2024-06-26T07:20:04.091653736Z] loading plugin "io.containerd.snapshotter.v1.zfs"...  type=io.containerd.snapshotter.v1
INFO[2024-06-26T07:20:04.092044678Z] skip loading plugin "io.containerd.snapshotter.v1.zfs"...  error="failed to find the mount info for \"/var/lib/docker/containerd/daemon/io.containerd.snapshotter.v1.zfs\": skip plugin" type=io.containerd.snapshotter.v1
INFO[2024-06-26T07:20:04.092127702Z] loading plugin "io.containerd.metadata.v1.bolt"...  type=io.containerd.metadata.v1
WARN[2024-06-26T07:20:04.092449242Z] could not use snapshotter devmapper in metadata plugin  error="devmapper not configured"
WARN[2024-06-26T07:20:04.092504522Z] could not use snapshotter btrfs in metadata plugin  error="failed to find the mount info for \"/var/lib/docker/containerd/daemon/io.containerd.snapshotter.v1.btrfs\""
INFO[2024-06-26T07:20:04.092667226Z] metadata content store policy set             policy=shared
INFO[2024-06-26T07:20:04.131919123Z] loading plugin "io.containerd.differ.v1.walking"...  type=io.containerd.differ.v1
INFO[2024-06-26T07:20:04.132343710Z] loading plugin "io.containerd.event.v1.exchange"...  type=io.containerd.event.v1
INFO[2024-06-26T07:20:04.132445278Z] loading plugin "io.containerd.gc.v1.scheduler"...  type=io.containerd.gc.v1
INFO[2024-06-26T07:20:04.134156175Z] loading plugin "io.containerd.lease.v1.manager"...  type=io.containerd.lease.v1
INFO[2024-06-26T07:20:04.134936874Z] loading plugin "io.containerd.nri.v1.nri"...  type=io.containerd.nri.v1
INFO[2024-06-26T07:20:04.135204712Z] NRI interface is disabled by configuration.  
INFO[2024-06-26T07:20:04.135335262Z] loading plugin "io.containerd.runtime.v2.task"...  type=io.containerd.runtime.v2
INFO[2024-06-26T07:20:04.136780846Z] loading plugin "io.containerd.runtime.v2.shim"...  type=io.containerd.runtime.v2
INFO[2024-06-26T07:20:04.136889861Z] loading plugin "io.containerd.sandbox.store.v1.local"...  type=io.containerd.sandbox.store.v1
INFO[2024-06-26T07:20:04.136997128Z] loading plugin "io.containerd.sandbox.controller.v1.local"...  type=io.containerd.sandbox.controller.v1
INFO[2024-06-26T07:20:04.137151186Z] loading plugin "io.containerd.streaming.v1.manager"...  type=io.containerd.streaming.v1
INFO[2024-06-26T07:20:04.137381395Z] loading plugin "io.containerd.service.v1.introspection-service"...  type=io.containerd.service.v1
INFO[2024-06-26T07:20:04.137487108Z] loading plugin "io.containerd.service.v1.containers-service"...  type=io.containerd.service.v1
INFO[2024-06-26T07:20:04.137618442Z] loading plugin "io.containerd.service.v1.content-service"...  type=io.containerd.service.v1
INFO[2024-06-26T07:20:04.137744162Z] loading plugin "io.containerd.service.v1.diff-service"...  type=io.containerd.service.v1
INFO[2024-06-26T07:20:04.137918027Z] loading plugin "io.containerd.service.v1.images-service"...  type=io.containerd.service.v1
INFO[2024-06-26T07:20:04.138062710Z] loading plugin "io.containerd.service.v1.namespaces-service"...  type=io.containerd.service.v1
INFO[2024-06-26T07:20:04.138178983Z] loading plugin "io.containerd.service.v1.snapshots-service"...  type=io.containerd.service.v1
INFO[2024-06-26T07:20:04.138304865Z] loading plugin "io.containerd.runtime.v1.linux"...  type=io.containerd.runtime.v1
INFO[2024-06-26T07:20:04.138744746Z] loading plugin "io.containerd.monitor.v1.cgroups"...  type=io.containerd.monitor.v1
INFO[2024-06-26T07:20:04.143291232Z] loading plugin "io.containerd.service.v1.tasks-service"...  type=io.containerd.service.v1
INFO[2024-06-26T07:20:04.144267999Z] loading plugin "io.containerd.grpc.v1.introspection"...  type=io.containerd.grpc.v1
INFO[2024-06-26T07:20:04.144510676Z] loading plugin "io.containerd.transfer.v1.local"...  type=io.containerd.transfer.v1
INFO[2024-06-26T07:20:04.145479023Z] loading plugin "io.containerd.internal.v1.restart"...  type=io.containerd.internal.v1
INFO[2024-06-26T07:20:04.147649868Z] loading plugin "io.containerd.grpc.v1.containers"...  type=io.containerd.grpc.v1
INFO[2024-06-26T07:20:04.147946032Z] loading plugin "io.containerd.grpc.v1.content"...  type=io.containerd.grpc.v1
INFO[2024-06-26T07:20:04.148203697Z] loading plugin "io.containerd.grpc.v1.diff"...  type=io.containerd.grpc.v1
INFO[2024-06-26T07:20:04.148557836Z] loading plugin "io.containerd.grpc.v1.events"...  type=io.containerd.grpc.v1
INFO[2024-06-26T07:20:04.148820349Z] loading plugin "io.containerd.grpc.v1.healthcheck"...  type=io.containerd.grpc.v1
INFO[2024-06-26T07:20:04.149525396Z] loading plugin "io.containerd.grpc.v1.images"...  type=io.containerd.grpc.v1
INFO[2024-06-26T07:20:04.149759774Z] loading plugin "io.containerd.grpc.v1.leases"...  type=io.containerd.grpc.v1
INFO[2024-06-26T07:20:04.150033791Z] loading plugin "io.containerd.grpc.v1.namespaces"...  type=io.containerd.grpc.v1
INFO[2024-06-26T07:20:04.150148390Z] loading plugin "io.containerd.internal.v1.opt"...  type=io.containerd.internal.v1
INFO[2024-06-26T07:20:04.152279675Z] loading plugin "io.containerd.grpc.v1.sandbox-controllers"...  type=io.containerd.grpc.v1
INFO[2024-06-26T07:20:04.152420187Z] loading plugin "io.containerd.grpc.v1.sandboxes"...  type=io.containerd.grpc.v1
INFO[2024-06-26T07:20:04.152514041Z] loading plugin "io.containerd.grpc.v1.snapshots"...  type=io.containerd.grpc.v1
INFO[2024-06-26T07:20:04.152656875Z] loading plugin "io.containerd.grpc.v1.streaming"...  type=io.containerd.grpc.v1
INFO[2024-06-26T07:20:04.152742394Z] loading plugin "io.containerd.grpc.v1.tasks"...  type=io.containerd.grpc.v1
INFO[2024-06-26T07:20:04.152850775Z] loading plugin "io.containerd.grpc.v1.transfer"...  type=io.containerd.grpc.v1
INFO[2024-06-26T07:20:04.153047468Z] loading plugin "io.containerd.grpc.v1.version"...  type=io.containerd.grpc.v1
INFO[2024-06-26T07:20:04.153099750Z] loading plugin "io.containerd.tracing.processor.v1.otlp"...  type=io.containerd.tracing.processor.v1
INFO[2024-06-26T07:20:04.153200063Z] skip loading plugin "io.containerd.tracing.processor.v1.otlp"...  error="no OpenTelemetry endpoint: skip plugin" type=io.containerd.tracing.processor.v1
INFO[2024-06-26T07:20:04.153250139Z] loading plugin "io.containerd.internal.v1.tracing"...  type=io.containerd.internal.v1
INFO[2024-06-26T07:20:04.153433114Z] skipping tracing processor initialization (no tracing plugin)  error="no OpenTelemetry endpoint: skip plugin"
INFO[2024-06-26T07:20:04.162601994Z] serving...                                    address=/var/run/docker/containerd/containerd-debug.sock
INFO[2024-06-26T07:20:04.162953977Z] serving...                                    address=/var/run/docker/containerd/containerd.sock.ttrpc
INFO[2024-06-26T07:20:04.163447135Z] serving...                                    address=/var/run/docker/containerd/containerd.sock
INFO[2024-06-26T07:20:04.165943652Z] containerd successfully booted in 0.213341s  
INFO[2024-06-26T07:20:04.331140698Z] stopping healthcheck following graceful shutdown  module=libcontainerd
INFO[2024-06-26T07:20:04.333518576Z] stopping event stream following graceful shutdown  error="context canceled" module=libcontainerd namespace=plugins.moby
failed to start daemon: Devices cgroup isn't mounted

Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?

As can bee seen I try to load an image, however I’m planning on pulling it, however currently I try to make it work with load for simplicity. It seems that my problem is that I can’t get dockerd running inside the chroot’ed rootfs.

Hi,

We had a similar topic before that wanted to pull the docker image by default when flashing.
Could you help to check if there is any useful info for your use case first?

Thanks.

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