TipsAndTricks/DockerOnImage: Difference between revisions

From Yocto Project
Jump to navigationJump to search
No edit summary
No edit summary
Line 1: Line 1:
This assumes you'd like to build an image that supports docker on a YP image.  This is pretty straightforward due to the great work done  on the meta-virtualization layer, mostly by people at Wind River.  This document will show how to get docker running on a Minnowboard (Turbot).  Note, these layers change, so this is accurate as of July 2017.
This assumes you'd like to build an image that supports docker on a YP image.  This is pretty straightforward due to the great work done  on the meta-virtualization layer, mostly by people at Wind River.  This document will show how to get docker running on a Minnowboard (Turbot).  Note, these layers change, so this is accurate as of July 2017.
== What Layers you Need ==
== What Layers Do You Need? ==
The main layer is meta-virtualization. This can be found using the layers.openembedded search app, Here's the [[https://layers.openembedded.org/layerindex/branch/master/layer/meta-virtualization/ meta-virtualiation]]  entry. As you can see from the dependency list, this layer requires oe-core,meta-oe, meta-networking, and meta-filesystems. Some of these (like meta-networking) have additional dependencies. Here's the complete list of additional layers you need:
The main layer is meta-virtualization. This can be found using the layers.openembedded search app, Here's the [[https://layers.openembedded.org/layerindex/branch/master/layer/meta-virtualization/ meta-virtualiation]]  entry. As you can see from the dependency list, this layer requires oe-core,meta-oe, meta-networking, and meta-filesystems. Some of these (like meta-networking) have additional dependencies. Here's the complete list of additional layers you need:
* [[https://git.yoctoproject.org/git/meta-virtualization meta-virtualization]]
* [[https://git.yoctoproject.org/git/meta-virtualization meta-virtualization]]
Line 18: Line 18:
   <AbsPath>/meta-openembedded/meta-networking \                                                                                                           
   <AbsPath>/meta-openembedded/meta-networking \                                                                                                           
   <AbsPath>/meta-openembedded/meta-filesystems \                                                                                                         
   <AbsPath>/meta-openembedded/meta-filesystems \                                                                                                         
   <AbsPath>/meta-virtualization \                                                                                                                      
   <AbsPath>/meta-virtualization \                      
  "
 
== What Configuration Changes Do you Need? ==
There are a number of configuration settings you need in your build/conf/local.conf in order to make this work. I'll list them below and try to explain why you need them:
<code>                                                                                               
# this gives us the linux-yocto kernel for an x86-64 machine like minnowboard                                                                           
MACHINE = "genericx86-64"
 
# Docker presumes systemd                                                                                                                               
DISTRO_FEATURES_append = " systemd"
VIRTUAL-RUNTIME_init_manager = "systemd"
DISTRO_FEATURES_BACKFILL_CONSIDERED = "sysvinit"
VIRTUAL-RUNTIME_initscripts = "systemd-compat-units"
 
# we need space for images                                                                                                                             
IMAGE_ROOTFS_EXTRA_SPACE = "10000000"
 
# The extra space takes us above 4gb, so                                                                                                               
# turn off hdd and iso images so they do                                                                                                               
# not break                                                                                                                                             
NOHDD="1"
NOISO="1"
 
# pick a kernel I know works:                                                                                                                           
PREFERRED_PROVIDER_virtual/kernel="linux-yocto"
PREFERRED_VERSION_linux-yocto="4.9%"
 
 
# add docker to the image                                                                                                                               
# connman to manage the networking                                                                                                                     
IMAGE_INSTALL_append = " docker docker-contrib connman connman-client \                                                                               
"
</code>

Revision as of 18:20, 7 July 2017

This assumes you'd like to build an image that supports docker on a YP image. This is pretty straightforward due to the great work done on the meta-virtualization layer, mostly by people at Wind River. This document will show how to get docker running on a Minnowboard (Turbot). Note, these layers change, so this is accurate as of July 2017.

What Layers Do You Need?

The main layer is meta-virtualization. This can be found using the layers.openembedded search app, Here's the [meta-virtualiation] entry. As you can see from the dependency list, this layer requires oe-core,meta-oe, meta-networking, and meta-filesystems. Some of these (like meta-networking) have additional dependencies. Here's the complete list of additional layers you need:

You need to add these (with absolute paths) to your build/conf/bblayers.conf file. BBLAYERS should look something like this:

BBLAYERS ?= " \                                                                                                                                          
 <AbsPath>/poky/meta \                                                                                                                                  
 <AbsPath>/poky/meta-poky \                                                                                                                             
 <AbsPath>/poky/meta-yocto-bsp \                                                                                                                        
 <AbsPath>/meta-openembedded/meta-oe \                                                                                                                  
 <AbsPath>/meta-openembedded/meta-python \                                                                                                              
 <AbsPath>/meta-openembedded/meta-networking \                                                                                                          
 <AbsPath>/meta-openembedded/meta-filesystems \                                                                                                         
 <AbsPath>/meta-virtualization \                        

What Configuration Changes Do you Need?

There are a number of configuration settings you need in your build/conf/local.conf in order to make this work. I'll list them below and try to explain why you need them:

                                                                                                
  1. this gives us the linux-yocto kernel for an x86-64 machine like minnowboard

MACHINE = "genericx86-64"

  1. Docker presumes systemd

DISTRO_FEATURES_append = " systemd" VIRTUAL-RUNTIME_init_manager = "systemd" DISTRO_FEATURES_BACKFILL_CONSIDERED = "sysvinit" VIRTUAL-RUNTIME_initscripts = "systemd-compat-units"

  1. we need space for images

IMAGE_ROOTFS_EXTRA_SPACE = "10000000"

  1. The extra space takes us above 4gb, so
  2. turn off hdd and iso images so they do
  3. not break

NOHDD="1" NOISO="1"

  1. pick a kernel I know works:

PREFERRED_PROVIDER_virtual/kernel="linux-yocto" PREFERRED_VERSION_linux-yocto="4.9%"


  1. add docker to the image
  2. connman to manage the networking

IMAGE_INSTALL_append = " docker docker-contrib connman connman-client \ "