Skip to content

Use Docker to build RIOT

Rotzbua edited this page Jul 18, 2019 · 16 revisions

Use Docker to build RIOT

Docker is a platform that allows packaging software into containers that can easily be run on any Linux that has Docker installed.

You can download a RIOT Docker container from the Docker Hub and then use that to build your project making use of all toolchains that we've preinstalled in the container.

Setup

First, install Docker. Probably sudo apt-get install docker (or equivalent) will be all you need.

You need to have permission to access the Docker daemon. There are two ways:

  • Your OS distribution may create a group called docker. If so, then adding yourself to that group (and logging out and in again) should grant you permission.
  • Execute docker with sudo. This is in fact the most secure and recommended setup (see here, here, here and here). No extra setup steps are needed. make should be instructed to use sudo by setting DOCKER="sudo docker" in the command line.

Then, download the pre-built RIOT Docker container:

# docker pull riot/riotbuild

This will take a while. If it finishes correctly, you can then use the toolchains contained in the Docker container: (from the riot root):

$ docker run --rm -i -t -u $UID -v $(pwd):/data/riotbuild riot/riotbuild ./dist/tools/compile_test/compile_test.py

Usage

The RIOT build system provides support for using the Docker container to build RIOT projects, so you do not need to type the long docker command line every time:

(from the directory you would normally run make, e.g. examples/default)

$ make BUILD_IN_DOCKER=1

If your user does not have permissions to access the Docker daemon:

$ make BUILD_IN_DOCKER=1 DOCKER="sudo docker"

to always use Docker for building, set BUILD_IN_DOCKER=1 (and if necessary DOCKER="sudo docker") in the environment:

$ export BUILD_IN_DOCKER=1

running make without specifying BUILD_IN_DOCKER=1 will still use Docker (because of the environment variable)

Troubleshooting

On some Ubuntu versions a make with BUILD_IN_DOCKER=1 cant resolve the host name of for example github.com. To fix this add the file /etc/docker/daemon.json with the address of your DNS Server.

Clone this wiki locally