Embedded Linux Development Using Yocto Project Cookbook(Second Edition)
上QQ阅读APP看书,第一时间看更新

How it works...

Instructing Docker to start the image creation process with a Ubuntu 16.04 image is as easy as starting the Dockerfile with the following:

FROM ubuntu:16.04

To inherit a Docker image, you use the Dockerfile FROM syntax.

Other commands used in the Dockerfile are:

  • RUN, which will run the specified command in a new layer and commit the result
  • ENV, to set an environmental variable
  • USER, which sets the username to use for RUN and CMD instructions following it
  • WORKDIR, which sets the working directory for RUN and CMD instructions that follow it
  • CMD, which provides the default executable for the container, in this case the Bash shell

The rest of the Dockerfile does the following:

  • Updates Ubuntu 16.04 to the latest packages
  • Installs Yocto dependencies
  • Sets up the locale for the container
  • Adds a new build user
  • Installs both Poky and the FSL community BSP release

The image has Poky installed at /opt/yocto/poky and the FSL community BSP installed at /opt/yocto/fsl-community-bsp. When it starts, the default directory is/home/build.

The usual way to work with a docker container is to instruct it to run commands but store the output in the host filesystem.

In our case, we instruct the container to run BitBake for us, but we map the build directories to the host by doing the external volume mapping when the container is initialized. In that way, all the build output is stored on the host machine.