Deploy your first Container¶
Overview
This guide will show you how to deploy your first container from DockerHub. For this example we will be using Node-RED.
Prerequisites
- Docker Engine set up and running on the device
- CMTK Device connected to the internet
Please read the official documentation first to learn how to set up docker and handle the device in general. Also consider the limited resources on the device. If a deployed container uses too much memory or CPU, the basic functionality of CMTK may be affected. In the worst case (if the container resources are not limited) you may not be able to access the web frontend. In such a case turn off the device and remove the offending SDcard then turn it back on. See section Deploy your first container for details on how to limit resources of a deployed container.
Step 1: Setting up Portainer¶
CMTK uses Portainer to manage docker containers. Access Portainer by clicking on the Open Portainer
button in Settings -> Docker Settings.
A new browser tab with Portainer will open.
An admin user is already created, Username: admin
Password: CMTK Passphrase
. The CMTK Passphrase is the password that was used to format the SD Card.
After login as admin the initial Portainer configuration can be completed and the main container interface may be accessed.
Step 2: Create a volume to persist data¶
Click on Volumes
in the navigation area on the left side to display all currently existing volumes. Next, click Add volume
.
Name your volume appropriately and click on Create volume
. All other defaults are fine for the purposes of this guide.
Step 3: Deploy your first container¶
Access the list of containers by clicking on Containers
in the navigation menu on the left. This page is listing all the currently active containers. Click on Add container
to add your own container.
Portainer will automatically generates unique names for deployed containers but feel free to enter a name to easily identify your new container. Next, enter the name of your image in the image configuration section. In this case the correct name is nodered/node-red
. You may specify any image available on DockerHub.
In order to access the container in your browser, you need to publish a network port in the network port configuration. Click on publish a new network port
and enter port 50000
for the host and 1880
for the container.
Note
You may only use ports in the range from 49152 to 65535 on the host side.
At the very bottom of the page you will find the Advanced container settings
section. Click on Volumes
within that section and map additional volume
. For Node-RED you need to map /data
in the container to the volume we have created previously.
There are two additional tabs in Advanced container settings
which should be checked and configured:
-
Runtime & Resources
allows setting memory and CPU limits of the deployed container. It is recommended to set limits so that there are still sufficient resources left for core CMTK functionality. Across all the deployed containers there should be at least 1GB left for core CMTK. -
Restart policy
allows to determine whether a container is started automatically. Please make sure that your deployed container works as expected before setting is to startAlways
.
Click on Deploy the container
to save the changes, pull the image from DockerHub and start the container. This may take a few minutes. Afterwards Portainer will return to the containers page.
Now you can access Node-Red using http://cmtk.local:50000. If you are using a different hostname or IP-address to access your device, replace cmtk.local accordingly.