Docker as build environment
Due to the compatibility issues in different OS platform, some tools such as automake or autoconf which is the popular tool in opensource to set up the compile environment, the building numerous open source projects could be failed because of unmatched tool versions on your building environment. In order to prevent this failure, Docker container that already has necessary tools and toolchains would be the promising building environment tools, it could help you to start the building and you are not required to install unnecessary tools to your OS platform.
For ODROID-N2, the Docker container based on Ubuntu 16.04 with toolchains is provided through Docker Hub. This page will briefly go through how you can use it.
Installation
Installing Docker
In order to run the Docker container, Docker must be installed on your system and Docker webpage provides the instructions for the various OS platforms and the versions. Between the variant of Docker services, Docker CE is strongly recommended to install.
Installing the container
Once your account is privileged to access Docker service, you can start to download and install the Docker image. For ODROID-N2, the Docker container based on Ubuntu 16.04 with toolchains is provided through Docker Hub, https://hub.docker.com/r/odroid/meson64-dev.
- host
$ docker pull odroid/meson64-dev:201901 201901: Pulling from odroid/meson64-dev 3b37166ec614: Pull complete 504facff238f: Pull complete ebbcacd28e10: Pull complete c7fb3351ecad: Pull complete 2e3debadcbf7: Pull complete 8200f2345b79: Pull complete 19b0cbc43f19: Downloading [===========================> ] 27.62MB/51.06MB 44413b1d22ad: Downloading [=======================================> ] 98.68MB/125.4MB 26eb8b89cad2: Download complete f70b2fb97e70: Download complete 2ac91b46f862: Download complete f065583f93e0: Download complete 25e2e434e6c5: Downloading [=====================> ] 48.28MB/111.1MB 7c9bfd7b4c30: Waiting 47492c161b55: Waiting 0dd0cecdfc05: Pulling fs layer e34313b986e1: Waiting a5a90a812114: Waiting 6c3b77dd78fc: Waiting e1f9544ef33e: Waiting 403a115e7e88: Pulling fs layer 9fd3394805a2: Waiting 8f0535da0557: Waiting
Downloaded Docker containers can be listed with the command docker images.
- host
$ docker images REPOSITORY TAG IMAGE ID CREATED SIZE odroid/meson64-dev 201901 1a26e3b18434 8 days ago 2.51GB
Getting into Docker container
In this example, the host OS platform is Ubuntu 18.04 and after starting Docker container with docker run … command, OS platform is switched to another one installed to the container.
- host
$ uname -a Linux paju.odroid.com 4.15.0-45-generic #48-Ubuntu SMP Tue Jan 29 16:28:13 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux $ cat /etc/lsb-release DISTRIB_ID=Ubuntu DISTRIB_RELEASE=18.04 DISTRIB_CODENAME=bionic DISTRIB_DESCRIPTION="Ubuntu 18.04.1 LTS"
You can simple get into the container and the default directory is /srv in the container.
- host
$ docker run --privileged -it odroid/meson64-dev:201901 To run a command as administrator (user "root"), use "sudo <command>". See "man sudo_root" for details.
Kernel version and OS platform version is switched from the host platform.
- host
odroid@e3b08b8268aa:/srv$ uname -a Linux e3b08b8268aa 4.15.0-45-generic #48-Ubuntu SMP Tue Jan 29 16:28:13 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux odroid@e3b08b8268aa:/srv$ lsb_release bash: lsb_release: command not found odroid@e3b08b8268aa:/srv$ cat /etc/lsb-release DISTRIB_ID=Ubuntu DISTRIB_RELEASE=16.04 DISTRIB_CODENAME=xenial DISTRIB_DESCRIPTION="Ubuntu 16.04.5 LTS"
Building
The toolchains for ODROID-N2 are already installed in the container, odroid/meson64-dev:201901.
- host
$ ls -l /opt/toolchains/ total 16 drwxr-xr-x 6 root root 4096 Feb 4 03:44 gcc-arm-none-eabi-6-2017-q1-update drwxr-xr-x 8 11827 9000 4096 Feb 16 2017 gcc-linaro-6.3.1-2017.02-x86_64_aarch64-linux-gnu drwxr-xr-x 7 1001 1001 4096 Nov 19 2013 gcc-linaro-aarch64-none-elf-4.8-2013.11_linux drwxr-xr-x 7 1001 1001 4096 Apr 17 2014 gcc-linaro-arm-none-eabi-4.8-2014.04_linux
For example, you alrady have downloaded the source tree of Buildroot in your host platform and willing to build it in the container, you must mount the source tree to a directory in the container. This can be simply done adding an argument -v $PWD:/srv to docker run.
This is the directory in the host platform.
- host
$ ls -l total 36 -r--r--r-- 1 tobetter tobetter 98 Aug 29 03:07 Makefile drwxr-xr-x 3 tobetter tobetter 4096 Jan 9 00:30 bootloader drwxr-xr-x 18 tobetter tobetter 4096 Feb 9 19:02 buildroot drwxr-xr-x 5 tobetter tobetter 4096 Nov 8 22:55 hardware drwxr-xr-x 3 tobetter tobetter 4096 Dec 3 23:03 kernel drwxr-xr-x 17 tobetter tobetter 4096 Nov 8 22:55 multimedia drwxr-xr-x 3 tobetter tobetter 4096 Aug 29 03:07 toolchain drwxr-xr-x 5 tobetter tobetter 4096 Feb 9 18:49 vendor
Docker container can be started,
- host
$ docker run -v $PWD:/srv -it odroid/meson64-dev:201901 To run a command as administrator (user "root"), use "sudo <command>". See "man sudo_root" for details. odroid@6020bc058acd:/srv$ ls -l total 36 -r--r--r-- 1 odroid 1000 98 Aug 28 18:07 Makefile drwxr-xr-x 3 odroid 1000 4096 Jan 8 15:30 bootloader drwxr-xr-x 18 odroid 1000 4096 Feb 9 10:02 buildroot drwxr-xr-x 5 odroid 1000 4096 Nov 8 13:55 hardware drwxr-xr-x 3 odroid 1000 4096 Dec 3 14:03 kernel drwxr-xr-x 17 odroid 1000 4096 Nov 8 13:55 multimedia drwxr-xr-x 6 odroid root 4096 Oct 10 15:51 output drwxr-xr-x 3 odroid 1000 4096 Aug 28 18:07 toolchain drwxr-xr-x 5 odroid 1000 4096 Feb 9 09:49 vendor odroid@6020bc058acd:/srv$ pwd /srv odroid@6020bc058acd:/srv$ whoami odroid odroid@6020bc058acd:/srv$ id -u 1000 odroid@6020bc058acd:/srv$ id -g 0