How to generate a yocto image with docker engine?

Hi,
I’m trying to run a mender image build with yocto that will run docker containers.

I do not find in the doc how to achieve this and using docker-artifact-gen then uploading the mender artifact and deploying it leads to errors in logs because docker engine is not present.
I suppose it is a matter of adding the right meta-layer to the build but how can I find which one and where to point sources to?

thanks!
Jean-Charles

Hi @jchdel!

Many people find Yocto a bit challening in the beginning.

So even though this is not strictly related to Mender, we do have a forum category with taking the first steps with Yocto here: https://hub.mender.io/c/tutorials/yocto-project

In particular, this might cover what you are looking for: https://hub.mender.io/t/how-to-install-packages-in-yocto-project

Let us know how it works out!

Hi @jchdel,

Welcome to Mender hub. You will need the meta-virtualization layer as a start. I don’t know the exact configuration changes needed but the docs in that layer should help.

Drew

Thanks for the links and pointers.

After quite a bit of trials and mostly errors…
I’m currently building with

 BBLAYERS ?= " \
  ${TOPDIR}/../sources/poky/meta \
  ${TOPDIR}/../sources/poky/meta-poky \
  ${TOPDIR}/../sources/poky/meta-yocto-bsp \
  ${TOPDIR}/../sources/meta-mender/meta-mender-core \
  ${TOPDIR}/../sources/meta-mender/meta-mender-demo \
  ${TOPDIR}/../sources/meta-mender/meta-mender-qemu \
  ${TOPDIR}/../../meta-openembedded/meta-oe \
  ${TOPDIR}/../../meta-openembedded/meta-python \
  ${TOPDIR}/../../meta-openembedded/meta-networking \
  ${TOPDIR}/../../meta-openembedded/meta-filesystems \
  ${TOPDIR}/../../meta-virtualization \
  "


echo 'IMAGE_INSTALL_append = " docker"' >> conf/local.conf
# also enhance storage size in conf/local.conf
bitbake -c menuconfig virtual/kernel
bitbake core-image-base

docker is installed but doesn’t run :frowning: br_netfilter kernel module is not present…

Docker has many Linux kernel dependencies and this can be quite frustrating to get right.

There is a helper script that you can run on your device,

wget https://github.com/moby/moby/raw/master/contrib/check-config.sh
chmod +x check-config.sh
./check-config.sh

This will tell you which kernel configs you are missing and need to enable.

Further make sure that you have kernel-modules installed as part of your image

Thanks for the hints; I finally manage to make docker run on mender image. For memory and documentation, on top of above bblayers.conf, local.conf had following changes from default:

MENDER_SERVER_URL = “https://hosted.mender.io
MENDER_TENANT_TOKEN = “*****”
MENDER_ARTIFACT_NAME = “release-docker-1”
MENDER_STORAGE_TOTAL_SIZE_MB = “16384”
MENDER_BOOT_PART_SIZE_MB = “32”
MENDER_DATA_PART_SIZE_MB = “8192”
DISTRO_FEATURES_append = " virtualization"
IMAGE_INSTALL_append = " docker"
CORE_IMAGE_EXTRA_INSTALL += " kernel-modules"

and I had to add aufs module to kernel with

bitbake -c menuconfig virtual/kernel

before running

bitbake core-image-base

1 Like

On which board do you run docker?
What is your kernel version?
What is your yocto version?
I am asking because I have it running without aufs. btrfs shouls works as well and on a recent version even ext4 I believe.
Do you plan to create docker images as well with yocto?

@robert.berger, you are right aufs is not needed.

I run currently my setup on two flavors of orange-pi-pc boards, a genericx86-64 board and a qemux86-64.
It runs poky warrior 2.7.3 with Linux version 4.19.63.

current plan is to have edge devices to pull docker images from a private repo based upon docker update module. Not sure yet if it will be the right way to go…