Docker Build Environment¶
Docker Introduction¶
Docker is a software platform that allows the creation, testing and distribution of applications via containers. Containers let you run your applications in resource-isolated processes. There are some similarities to virtual machines, but containers are more portable, more resource-friendly, and enables faster software delivery cycles. Often used with docker there's a companion tool known as docker-compose: compose is used for defining and running multi-container Docker applications.
You can check Docker online documentation at: https://docs.docker.com/get-started/ https://docs.docker.com/compose/ https://training.play-with-docker.com/ https://docker-curriculum.com/
This guide describes how to use Docker as a Host build environment for building Variscite Yocto, Android, Debian and Boot2Qt images.
Why Build using Docker?¶
Each version of Yocto, Android, Debian and Boot2Qt has unique Host requirements (e.g. Ubuntu 16.04, Ubuntu 18.04...). This can be cumbersome during development if you are working on legacy projects and new projects at the same time. Over time, we've all come up with our own solutions to this problem by using Virtual Machines or even keeping old computers just to build an occasional image.
Docker is a great solution to this problem and provides:
- A git revision controlled build environment
- Can run on any OS and hardware that supports the Docker Runtime
- Does not require strict allocation of RAM and hard drive memory
- Has very little CPU/IO overhead, does not impact build time
- Containers start and stop in 1-2 seconds
Docker's efficiency allows multiple containers to be run simultaneously without burdening the host OS.
Setting Up Host Computer¶
Host Hardware¶
For building Linux / Android images, it is recommended to have a dedicated build computer. A machine with a 16 cores/32 threads CPU, 64GiB of RAM and a 2TB SSD is recommended. Compile time is generally reduced linearly with the number of CPU cores.
Host OS¶
Install the latest LTS version of Ubuntu: https://ubuntu.com/download
After a fresh installation, install Docker:
Give permissions to run Docker without sudo:
Install Linux Headers (required for some Yocto versions):
Logout and login again for permissions to take effect.
Using Variscite's Docker Container¶
Get the source code¶
Clone Variscite's Docker container repository:
Starting a container¶
Start your first Docker container. The first time you start the container, it will take some time to build the container.
After the container finishes building, it will enter the docker container with an interactive shell in the current working directory.
Start a Ubuntu 14.04 container:
Start a Ubuntu 16.04 container:
Start a Ubuntu 18.04 container:
Start a Ubuntu 20.04 container:
Start a Ubuntu 22.04 container:
See run options:
Using the sudo command¶
If you need to run a command using 'sudo' inside the container, the default password is 'ubuntu'
Building an image¶
Example: Yocto¶
This example shows how to build a Yocto image for the VAR-SOM-MX8X using Docker. In general, the process is the same for all target Operating Systems. Please follow Variscite's build guide and host requirements for your specific releases.
Make a working directory from your Host OS:
Download the source code:
repo init -u https://github.com/varigit/variscite-bsp-platform.git -b refs/tags/mx8x-yocto-scarthgap-6.6.52_2.2.0-v1.2
Start a Ubuntu 20.04 Docker container:
Note: the "-p" option starts Docker in privileged mode, which allows access to host devices and is necessary for building Debian images.
Build a Yocto image in the container:
vari@abe078d0f67c:/workdir$ MACHINE=imx8qxp-var-som DISTRO=fsl-imx-xwayland . var-setup-release.sh build_xwayland
The output images can be accessed from your host computer:
Example: Boot2Qt¶
This example shows how to build a B2Qt image for the VAR-SOM-MX8X using Docker. In general, the process is the same for all target Operating Systems. Please follow Variscite's build guide and host requirements for your specific releases.
Make a working directory from your Host OS:
Start a Ubuntu 20.04 Docker container:
Get the source code:
Build the image:
The output images can be accessed from your host computer: