LoginSignup
1
1

More than 1 year has passed since last update.

PLCNextへDocker(balena-engine)を導入するまで

Posted at

はじめに

PHOENIX CONTACT社製PLCNextへdocker(balena-engine)を導入するまでの手順です。
IoTのエッジコンピューティングできる機器を模索しており、今回のPLCNextにてエッジ処理を
Node-redにて実現する事を想定しています。

balena-engineが推奨らしく、コマンドはdockerコマンドと同じっぽいです。

PLCNextの基本設定は省略します。

前提

  • sshが使えること(windowsならputtyやteratermなど)
  • PLCnext firmware 2020.6 であること
  • PLCNextのIPアドレス設定が済み、インターネット接続が可能なこと
  • ssh接続ができる状態であること
  • PLCNextのsu -になれること
  • 時刻が正しいこと
    • 時刻がずれていると、docker hubよりイメージをダウンロードする際にx509証明書の有効期限が切れていると言われ、docker pullができません。

balena-engineのインストール

参考:PLCnext Technology compatible container runtimes - Docker, Moby, balenaEngine

参考:Installation of Balena Engine

  • ssh接続
  ssh admin@192.168.xxx.xxx

  Warning: This device is for authorized use only!
  This device is for the use of authorized users only.
  Individuals using it and all user actions on this device may be,
  monitored, recorded, copied and audited.
  Unauthorized use, without authority, or in excess of authority, is prohibited.
  By continuing to use this device you indicate your
  awareness of and consent to these terms of use.

  Warnung: Dieses Gerät ist nur für den autorisierten Gebrauch!
  Dieses Gerät darf nur von autorisierten Benutzern verwendet werden.
  Personen, die es verwenden, und alle Benutzeraktionen auf diesem Gerät können,
  überwacht, aufgezeichnet, kopiert, und auditiert werden.
  Die unautorisierte Verwendung ist nicht erlaubt.
  Durch die weitere Verwendung dieses Geräts erklären
  admin:b0e95e76@192.168.xxx.xxx's password: {パスワード入力}

パスワードを聞かれるので、{機器のデフォルトパスワード}と入力

  • balena-engin関連のディレクトリをgitより cloneする

SSL認証エラーが出る場合があるので、gitの設定を変更しておく。

  root@axcf2152:git config --global http.sslVerify false

.gitconfigの内容が下記となっていればOK

  root@axcf2152:~# cat .gitconfig
  [http]
    sslVerify = false
  • 関連ファイルをclone

    # Download the Project
    root@axcf2152:git clone https://github.com/PLCnext/Docker_GettingStarted.git
    
  • balena-engineをインストール

    # Execute Setup.sh in archive
    root@axcf2152:cd Docker_GettingStarted
    # setup.shに実行権限付与
    root@axcf2152:~/Docker_GettingStarted# chmod +x setup.sh
    
  • セットアップ用のshell実行

    # セットアップ実行
    root@axcf2152:~/Docker_GettingStarted#./setup.sh
    
    Install balenaEngine(recommend): 1
    Install Docker: 2
    
    Version xx.xx.xx (let empty for default balenaEngine 18.9.7, Docker 19.03.8): 
    
  • 再起動する

    shutdown -r now
    
  • 開発においては、firewallは不要なので削除する

    update-rc.d -f firewall remove
    
  • balena-engineの起動

    root@axcf2152:~# /etc/init.d/balena start
    
  • balena-engineの終了

    root@axcf2152:~# /etc/init.d/balena stop
    
  • pullしたdockerイメージの確認

    root@axcf2152:~# balena-engine images
    Result:
    CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES
    
  • 稼働中のコンテナの確認

    root@axcf2152:~# balena-engine ps
    CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS                       PORTS                    NAMES
    b86e0eb602c7        nodered/node-red    "npm --no-update-not…"   About an hour ago   Up About an hour (healthy)   0.0.0.0:1880->1880/tcp   mynodered
    
    balena-engine pull nodered/node-red
    
    balena-engine run -it -p 1880:1880 -v node_red_data:/data --name mynodered nodered/node-red
    

    https://docs.docker.com/engine/reference/commandline/cli/

    基本的なコマンドはdockerコマンドと同じなので、以下を参照のこと

    Running under Docker

    nodered/node-red

    balena-engineでもdocker-hubからdockerイメージをpullできる。作成したFLOWsデータは、dockerコンテナが停止すると消えてしまうので、ホストのディレクトリと関連づけしておく必要あり。

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1