Setting up with Docker

To get started, install Docker. On Ubuntu for instance (you’ll need set up the repository; see install-docker-ce for details):

sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin

Make sure your user is added to the unix group docker:

sudo usermod -aG docker <your-user>

Download the Contiki-NG image:

docker pull contiker/contiki-ng

This will automatically download contiker/contiki-ng:latest, which is the image used in CI and which we recommend for development. If you wish to use a different image version please follow the guidelines in the start of the article. The image is meant for use with Contiki-NG as a bind mount, which means you make the Contiki-NG repository on the host accessible from inside the container. This way, you can work on the codebase using host tools / editors, and build/run commands on the same codebase from the container. If you do not have it already, you need to check out Contiki-NG:

git clone https://github.com/contiki-ng/contiki-ng.git
cd contiki-ng
git submodule update --init --recursive

Then, it is a good idea to create an alias that will help start docker with all required options. On Linux, you can add the following to ~/.profile or similar, for instance, to ~/.bashrc:

export CNG_PATH=<absolute-path-to-your-contiki-ng>
alias contiker="docker run --privileged --sysctl net.ipv6.conf.all.disable_ipv6=0 --mount type=bind,source=$CNG_PATH,destination=/home/user/contiki-ng -e DISPLAY=$DISPLAY -e LOCAL_UID=$(id -u $USER) -e LOCAL_GID=$(id -g $USER) -v /tmp/.X11-unix:/tmp/.X11-unix -v /dev/bus/usb:/dev/bus/usb -ti contiker/contiki-ng"
arcslab@arcslab-XPS-8950:~$ contiker
To run a command as administrator (user "root"), use "sudo <command>".
See "man sudo_root" for details.

user@7aa37a4ab022:~/contiki-ng$ 

You will be under /home/user/contiki-ng in the container, which is mapped to your local copy of Contiki-NG.

Additional shell for existing container

Typing contiker as above will launch a new container. Sometimes it is useful to have multiple terminal sessions within a single container, e.g., to run a tunslip6 on one terminal and other commands on another one. To achieve this, start by running:

arcslab@arcslab-XPS-8950:~$ docker ps
CONTAINER ID   IMAGE                 COMMAND                  CREATED         STATUS         PORTS     NAMES
7aa37a4ab022   contiker/contiki-ng   "/usr/local/bin/rema…"   9 seconds ago   Up 8 seconds             wonderful_sinoussi

This will present you with a list of container IDs. Select the ID of the container you wish to open a terminal for and then

arcslab@arcslab-XPS-8950:~$ docker exec -it wonderful_sinoussi /bin/bash
root@7aa37a4ab022:~/contiki-ng# 

Last updated