intelli lab
intelli lab

Reputation: 21

How to run Contiki/Cooja with docker?

I am following along here:

https://docs.contiki-ng.org/en/master/doc/getting-started/Docker.html

I am a bit lost at this step, I can pull the docker image, but why then do I have to do a git clone?

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

I have pulled the image as below:

>:~/docker$ docker images contiker/contiki-ng
REPOSITORY            TAG       IMAGE ID       CREATED       SIZE
contiker/contiki-ng   latest    23438abb7b7f   7 days ago    5.28GB
contiker/contiki-ng   master    2731c751aa2c   2 years ago   7.11GB
>:~/docker$

But how do I run it?

What am I expecting?

I am expecting to be able to download the contiki image and then be able to run it.

EDIT

I got this working/running the cooja simulator: Not sure what I did that was different. but for ref let me note:

I followed this (let me come back to this again to confirm if I work out what I did, but i think i just needed to install VcXsrv ):

How to Run
Start VcXsrv (run XLaunch.exe)

Open cmd.exe (you can use PowerShell if you want)

Hit the following command (replace /c/Users/foobar/contiki-ng with a location of contiki-ng local repository in your environment)

C:\> docker run --privileged --sysctl net.ipv6.conf.all.disable_ipv6=0 --mount type=bind,source=/c/Users/foobar/contiki-ng,destination=/home/user/contiki-ng -e DISPLAY="host.docker.internal:0.0" -ti contiker/contiki-ng
Tested with Windows 10, version 1809.

pic of cooja running

Upvotes: 1

Views: 86

Answers (1)

kfx
kfx

Reputation: 8537

Follow the instructions from the documentation:

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"

To start a bash inside a new container, simply type:

contiker

Personally I add the alias comment to my .bashrc file so that the contiker command is always available.

Upvotes: 0

Related Questions