Skip to content

Container Preparation

HCC2 Docker containers require packaging into a Mender file and then signing before they can be deployed to a HCC2 device.

The first step is to prepare the docker-compose.yml that will be used to deploy your application container each time the HCC2 is started.

Editing docker-compose.yml

In your development environment: change Directory to: Your App Home Folder

Copy the file : docker-compose.yml to : docker-compose-<<app name>>.yml

For Example:

Edit the file: docker-compose-<<app name>>.yml.

Remember:

  • <app name> is the name of your app (e.g. pyapp for our example).
  • <tag name> is the tag associated with your app image (e.g. 0.0.0 for our example).

It should look like this:

---
version: '3.7'

services:
  pyapp:                              # name of your app    
    image: sdk-docs/pyapp:0.0.0       # image source/ tag (used in the Docker push)
    container_name: pyapp             # name of your app
    restart: on-failure
    read_only: true
    networks:
      - network1
    environment:
      HOST: modbus_0                  # HCC2 Modbus Server host (internal hostname, for external use IP address)
      PORT: 25002                     # HCC2 Modbus Server port (internal port that maps to 502 externally)
      UNIT: 1                         # Modbus client unit
      TIME_PERIOD: 1000               # time between polls (ms)
      CONTROL_TIME_PERIOD: 1000       # time between controls (ms)
      TIMEOUT: 500                    # reply timeout (ms)
      RETRIES: 1                      # number of retries
    tmpfs:                            # map to temp dir
      - /temp:uid=5678,gid=5678
    volumes:                          # define container
      - vol1:/app-dir1                # internal persistence
networks:         
  network1:
    name: edgenet
    external: true
volumes:                              # volumes definition
  vol1:
    name: vol1
...

The image: parameter should be replaced with your Docker image path/location.

Danger

Please review the Rules & Best Practices section when designing your application. Badly designed/written applications can impact HCC2 performance, and/or degrade the life expectancy of flash storage.

Once you have finished editing your application yml file, copy it to your hcc2devtools folder.

For example, run the following commands:

cp $HOME/edgesdkexample/docker-compose-<<appname>>.yml $HOME/hcc2devtools

Result

You are now ready to sign your application.