User Tools

Site Tools


IoTivity + DOCKER

If you are working or deploying a cloud based IoTivity solution, you have to build and deploy more then one component. The IoTivity cloud stack is composed of 4 subsystems, Interface, Account Server, Resource Directory and Message Queue. These components also have some dependencies as the Apache Kafka, the Zookeeper and the MongoDB.

To start a development is bit tedious and requires preparation of an whole environment. In case of a production or a test deployment, you have to install all dependencies on the machine. In case of a multi-node system you have to define what will run on which machine without orchestration possibilities.

Because of these demands the IoTivity was dockerized. Each cloud subsystem is in the separate Docker Container.

Setup Docker

Follow official steps for the Docker CE installation here. When you've successfully installed the Docker, initialize the Docker Swarm. More info about the Swarm can be found here.

docker swarm init

If you're setting up an environment with multiple machines, for example cluster of Amazon EC2s, run that command on one of the instances and others should join this manager. After executing the command you'll get as response the command for other EC2 instances.

Docker compose file

The docker compose file contains all required services for running the whole IoTivity cloud stack. You can of course run container separately if you need.

Docker compose file is available from version 1.3 and you can find it here.

IoTivity stack is composed from:

Each docker container supports some environment variables. Kafka,Zookeeper and MongoDB are documented on links above.

Available environment variables for IoTivity components (with it's default values):


HC_PROXY_MODE=0 //if enabled, exposed port 80
WEBSOCKET_MODE=0 //if enabled, exposed port 8000
RESOURCE_DIRECTORY_ADDRESS iotivity-resourcedirectory
ACCOUNT_SERVER_ADDRESS iotivity-accountserver
MESSAGE_QUEUE_ADDRESS iotivity-messagequeue

Account Server


Resource Directory


Message Queue

ZOOKEEPER_ADDRESS kafka-zookeeper
KAFKA_ADDRESS kafka-zookeeper

Start Cloud

If you downloaded docker-compose.yml file and initialized Docker Swarm, you can start the whole IoTivity Cloud.

docker stack deploy -c docker-compose.yml iotivity

This will create the services.

$ docker service ls

ID            NAME                                 MODE        REPLICAS  IMAGE
gjvofxbuowbd  iotivity_iotivity-resourcedirectory  replicated  0/1       iotivity/resourcedirectory:latest
h346tu7jhtwy  iotivity_iotivity-accountserver      replicated  0/1       iotivity/accountserver:latest
ppzwa5qilvpf  iotivity_iotivity-messagequeue       replicated  0/1       iotivity/messagequeue:latest
uasfbfwijf38  iotivity_kafka-zookeeper             replicated  0/1       spotify/kafka:latest
vbj8sq867tib  iotivity_mongodb                     replicated  0/1       mongo:latest
wfyrlyd9kpz5  iotivity_iotivity-interface          replicated  0/1       iotivity/interface:latest

First execution will take some time because it has to download all layers of containers. You can then verify if containers are running.

$ docker ps -a

CONTAINER ID        NAMES                                                             STATUS
9d7942a69a78        iotivity_iotivity-interface.1.62y62ep1yf2fmvsd6zarlr08g           Up 2 minutes
ec98ae521897        iotivity_iotivity-resourcedirectory.1.2mccf9wtbupsfc9try41npv4u   Up 2 minutes
ad846efa6a8f        iotivity_iotivity-accountserver.1.fz9zn6rwmqozf21oirpsxgnfo       Up 2 minutes
716e394ea5cd        iotivity_iotivity-messagequeue.1.ocgx2mukr316sqqvidtc87z1x        Up 2 minutes
0d727b7c0e65        iotivity_kafka-zookeeper.1.ucyt0njcqfdhfiq2dn9fqs2id              Up 2 minutes
e8b228d5c36a        iotivity_mongodb.1.sql4vbscwvdajdxwk15ok5r7h                      Up 2 minutes

You can check the logs of any container.

$ docker logs 9d
log4j:WARN No appenders could be found for logger (io.netty.util.internal.logging.InternalLoggerFactory).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See for more info.
2017-05-17 07:15:19:958 [V] ... Connected, Address: iotivity-accountserver/
2017-05-17 07:15:19:959 [V] ... Connected, Address: iotivity-resourcedirectory/
2017-05-17 07:15:19:966 [V] ... Connected, Address: iotivity-messagequeue/
press 'q' to terminate

Now you can access IoTivity Cloud Interface on it's default port 5683.

If you're running IoTivity Cloud stack on multiple nodes of the Docker Wwarm, they are distributed automatically and you can use address of any node/manager in swarm to access IoTivity cloud regardless the node when it's running. Docker Swarm has it's own DNS and knows which service is listening on port 5683.

If you want to stop the IoTivity cloud stack, execute:

docker stack rm iotivity

Enjoy and if you have any questions, open a question on the Stackoverflow with the tag iotivity.

docker.txt · Last modified: 2017/05/17 08:51 by Ondrej Tomcik