...
Docker defines a container as a "standard unit of software". Container images package an application and all of its dependencies enabling it to run quickly and reliably across platforms. A container is isolated from other processes and other containers running on the same platform unless interfaces are explicitly defined. Docker containers provide a standard, lightweight and secure virtualization solution when a full hypervisor is overkill. Unlike hypervisors that virtualize the hardware, containers are lightweight because only the OS is virtualized. Containers rely on kernel features such as namespaces, cgroups and unionfs.
Docker provides:
- Docker Engine for running containerscontainer runtime
- Docker tools for creating, deploying and managing containers
- Docker Hub repository for hosting container images
This wiki assumes you have a working knowledge of Yocto. It will walk you through how to build and deploy Docker on Zynq Ultrascale+ with a Yocto flow . Docker has been tested on the ZCU102.in the following four configurations:
- systemd on a flash filesystem
- systemd on a ramdisk
- sysvinit on a flash filesystem
- sysvinit on a ramdisk
Requirements
- ZCU102 Eval Board
- Linux host machine or VM
- Internet access
Testing
...
Releases
rel-v2018.3 (Rocko)
Platforms
ZCU102
meta-virtualization Layer
The Docker recipe is included in the meta-virtualization
layer. The Xilinx Yocto manifest instructs repo
to automatically clone meta-virtualization, so there is no need to clone it manually unless you are using a Xilinx an unsupported Yocto flow. You can verify that the virtualization layer is installed in the sources
directory and that it's included in the bblayers.conf
. From this layer we will be building and installing the docker
and docker-contrib
packages. We will add this to a Docker machine configuration later.
...
Linux Configuration
The default zcu102 ZCU102 kernel configuration does not have all the required CONFIG
options for Docker, so we will need to turn them on through a configuration fragment. If you don't already have a kernel recipe directory in your layer, create the directory structure as shown below in your custom layer.
...
Next edit the linux-xlnx_%.bbappend
file as shown below and add the docker.cfg
. Note the wildcard , "%
, is "
is used to match any kernel version.
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
FILESEXTRAPATHS_prepend := "${THISDIR}/cfg:" SRC_URI_append = " file://docker.cfg" |
Add a docker.cfg
file in a the cfg directory and add the CONFIG
requirements shown in the listing below. The script from the Moby Project was used to determine these (more on this later).
...
In order to simplify the network manager on an embedded systemssystem, connman
is recommended to manage the NICnetwork adapter. This is completely optional. Without connman
, you will need to setup the networkd
service unit configuration files . You may add connamn
using your local.conf
or your <machine>.conf
. which is beyond the scope of this wiki. Last the loglevel
was downgraded to level 6 and audit
turned off from the kernel command line to reduce console chatter.
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
# Inherit all the properties from the zcu102-zynqmp machine
require conf/machine/zcu102-zynqmp.conf
# Reuse the fdt for the zcu102 bsp
YAML_DT_BOARD_FLAGS_pn-device-tree = "{BOARD zcu102-rev1.0}"
# Downgrade the loglevel to reduce console chatter and disable audit
KERNEL_BOOTARGS_append_pn-u-boot-zynq-uenv = " loglevel=6 audit=0"
# Include docker and docker-contrib in the image
IMAGE_INSTALL_append = " docker docker-contrib"
# Comment these out to use the default sysvinit
DISTRO = "petalinux-systemd"
IMAGE_INSTALL_append = " connman" |
If you want to boot with an initramfs
, add the variables in the listing below to your <machine>.conf
or local.conf
and observe the Ramdisk ramdisk info note below when running Docker.
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
# Remove wic because it causes circular dependencies with bundled initramfs IMAGE_FSTYPES_remove = "wic.qemu-sd" INITRAMFS_IMAGE = "petalinux-image-minimal" INITRAMFS_IMAGE_BUNDLE = "1" |
Distro Configuration (systemd)
Info | ||
---|---|---|
| ||
This section is optional and only required for |
...
Warning | ||
---|---|---|
| ||
|
HDF
Info | ||
---|---|---|
| ||
This section is optional. If you are using a custom HDF, then you may skip this section. |
...
The bitbake
command below assumes you are building a docker-systemd-zcu102-zynqmp.conf
machine which includes the configurations for Docker on a ZCU102. If you are making setting the configurations in your local.conf
, then you may target any machine such as zcu102-zynqmp
.
...
If you want to build Docker with sysvinit
, then you can may create another machine docker-zcu102-zynqmp.conf
and comment out the systemd
lines as noted in the docker-systemd-zcu102-zynqmp.conf
listing above.
...
Docker expects to run from a non-RAM based root filesystem since it uses pivot_root
to jail the container. For that reason it's recommended that you setup an SD card with VFAT and Ext4 partitions. Once your SD card is partitioned, copy the boot images to the VFAT partition and extract the rootfs to the Ext4 partition. These images are available in the deploy/images
directory of the machine you built. Copy the images as shown below noting that the VFAT partition is mounted on boot
and the Ext4 partition is mounted on rootfs
. This example is using the dtb
that is built from the kernel tree. If you are using a custom HDF, you will want to use the dtb
compiled from the DTG and so make sure that uEnv.txt
is using the correct dtb
.
...