PLCNEXT#AXCF 2152にdocker,podmanを試してみよう

PodmanとDockerは、両方ともコンテナを作成、管理、実行するためのContainer Rutnimeで、AXCF 2152がFirmware 2023.0以後はDefaultにpodmanがインストールされています。

この記事ではAXCF 2152におけるDockerとPodmanの導入方法について説明します。よろしくおねがいします。

Basic Setup

Check SD Card

Web Serverにアクセスし、Security>SD Cardをクリックします。

Support external SD CardのCheckboxを入れ、InformationがSD card support is activated のMessageが表示されたかを確認してください。

root password setup

sudo passwd root コマンドでルードのPasswordを設定します。

admin@axcf2152:~$ sudo passwd root

We trust you have received the usual lecture from the local System
Administrator. It usually boils down to these three things:

    #1) Respect the privacy of others.
    #2) Think before you type.
    #3) With great power comes great responsibility.

Password: 

Configure new password

新しいパスワードを入力します。

New password:
Retype new password:
passwd: password updated successfully
admin@axcf2152:~$ 

Login with root

suコマンドでルートLoginします。

admin@axcf2152:~$ su
Password:
root@axcf2152:/opt/plcnext/# 

Check with Internet

8.8.8.8をPingしAXCF 2152とInternetが接続しているかをCheckします。

root@axcf2152:/opt/plcnext/# ping google.com
PING google.com (142.251.222.46): 56 data bytes
64 bytes from 142.251.222.46: seq=0 ttl=117 time=4.785 ms
64 bytes from 142.251.222.46: seq=1 ttl=117 time=4.728 ms
64 bytes from 142.251.222.46: seq=2 ttl=117 time=4.470 ms
64 bytes from 142.251.222.46: seq=3 ttl=117 time=4.273 ms

Play with Docker

ここからはAXCF 2152にDockerをインストールする方法を説明します。

Reference Link

PLCNEXT#Play with Influxdb
PLCNEXT#Play with InfluxDB x telegraf

Clone from Github

Githubから/PLCnext/Docker_GettingStarted.gitをCPUにCloneします。

root@axcf2152:/opt/plcnext/# git clone https://github.com/PLCnext/Docker_GettingStarted.git
Cloning into ‘Docker_GettingStarted’…
fatal: unable to access ‘https://github.com/PLCnext/Docker_GettingStarted.git/’: SSL certificate problem: certificate is not yet valid

If Error

もしcertificate is not yet validのエラーが発生した場合、Configuration>Data and TimeでCPUの時刻を修正します。

DefaultではNTP Serverが作成されていません。

これで時間も同期できました。

Reference Link

下記のLinkで参考にしてください。

PLCNEXT#SSL Certificate problem cerificate is not yet valid

Try Again

時間設定し、もう一度試したら無事にCloneできました。

root@axcf2152:/opt/plcnext/# git clone https://github.com/PLCnext/Docker_GettingStarted.git
Cloning into ‘Docker_GettingStarted’…
remote: Enumerating objects: 524, done.
remote: Counting objects: 100% (524/524), done.
remote: Compressing objects: 100% (247/247), done.
remote: Total 524 (delta 271), reused 470 (delta 223), pack-reused 0
Receiving objects: 100% (524/524), 967.58 KiB | 1.86 MiB/s, done.
Resolving deltas: 100% (271/271), done.

Change Rights

Docker_GettingStartedの権限を実行できるように変更します。

root@axcf2152:/opt/plcnext/Docker_GettingStarted# chmod +x setup.sh
root@axcf2152:/opt/plcnext/Docker_GettingStarted# 

Run setup.sh

./setup.shを実行しSetup開始します。

root@axcf2152:/opt/plcnext/Docker_GettingStarted# ./setup.sh
Please choose your container runtime:
      Install balenaEngine(recommend): 1
      Install Docker: 2
      Cancel installation: [C]ancel

Choose Docker

どっちをインストールしますか?って聞かれます。2を入力しDockerを選択します。

root@axcf2152:/opt/plcnext/Docker_GettingStarted# ./setup.sh
Please choose your container runtime:
      Install balenaEngine(recommend): 1
      Install Docker: 2
      Cancel installation: [C]ancel
      2 

Confirm

docker-composeをインストールしますか?って聞かれます。Yesで進みます。

インストールに成功した場合に、最後にDocker installation successful!のメッセージが表示されます。

Do you wish to install docker-compose?
      yes
Starting Docker installation…
Connecting to download.docker.com (13.249.167.90:443)
wget: note: TLS certificate validation not implemented
saving to ‘docker-19.03.8.tgz’
docker-19.03.8.tgz    29% |****************************

Connecting to download.docker.com (13.249.167.90:443)
wget: note: TLS certificate validation not implemented
saving to ‘docker-19.03.8.tgz’
docker-19.03.8.tgz   100% |************************************************************************************************************************************************************| 55.6M  0:00:00 ETA
‘docker-19.03.8.tgz’ saved
docker/docker
docker/docker-proxy
docker/containerd
docker/ctr
docker/runc
docker/docker-init
docker/dockerd
docker/containerd-shim
Adding system startup for /etc/init.d/docker.
Starting Docker: docker.
Starting docker-compose installation…
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 –:–:– –:–:– –:–:–     0
100 20.7M  100 20.7M    0     0  4317k      0  0:00:04  0:00:04 –:–:– 4876k
        Docker installation successful!

Try Docker

Terminalでdockerコマンドを実行すると出力があればOKです。

root@axcf2152:/opt/plcnext/Docker_GettingStarted#docker

Usage:  docker [OPTIONS] COMMAND

A self-sufficient runtime for containers

Options:
      –config string      Location of client config files (default “/home/root/.docker”)
  -c, –context string     Name of the context to use to connect to the daemon (overrides DOCKER_HOST env var and default context set with “docker context use”)
  -D, –debug              Enable debug mode
  -H, –host list          Daemon socket(s) to connect to
  -l, –log-level string   Set the logging level (“debug”|”info”|”warn”|”error”|”fatal”) (default “info”)
      –tls                Use TLS; implied by –tlsverify
      –tlscacert string   Trust certs signed only by this CA (default “/home/root/.docker/ca.pem”)
      –tlscert string     Path to TLS certificate file (default “/home/root/.docker/cert.pem”)
      –tlskey string      Path to TLS key file (default “/home/root/.docker/key.pem”)
      –tlsverify          Use TLS and verify the remote
  -v, –version            Print version information and quit

Management Commands:
  builder     Manage builds
 config      Manage Docker configs
  container   Manage containers
  context     Manage contexts
  engine      Manage the docker engine
  image       Manage images
 network     Manage networks
  node        Manage Swarm nodes
  plugin      Manage plugins
 secret      Manage Docker secrets
 service     Manage services
  stack       Manage Docker stacks
  swarm       Manage Swarm
 system      Manage Docker
  trust       Manage trust on Docker images

Install Node-red

最後はこのコマンドでNode-redをインストールします。

docker run -it –restart unless-stopped -p 1880:1880 –network=host –privileged –name=mynodered nodered/node-red

root@axcf2152:/opt/plcnext/Docker_GettingStarted# docker run -it –restart unless-stopped -p 1880:1880 –network=host –privileged –name=mynodered nodered/node-red

Unable to find image ‘nodered/node-red:latest’ locally
latest: Pulling from nodered/node-red
a6b45ace95f4: Pull complete
fda70e3c8913: Downloading [=================>                                 ]  11.84MB/34.23MB
dc0281435920: Download complete
67d57a1ee6d6: Download complete
8a47ee1d653d: Download complete
8b31a1a18921: Download complete
f8cb693e313b: Downloading [=================================>                 ]  6.232MB/9.406MB
4f4fb700ef54: Download complete
7bf0029a31f4: Download complete
37f666fd45d0: Download complete
85e2c14cc42d: Download complete
fcc9c721c42b: Waiting

———————————————————————
Your flow credentials file is encrypted using a system-generated key.

If the system-generated key is lost for any reason, your credentials
file will not be recoverable, you will have to delete it and re-enter
your credentials.

You should set your own key using the ‘credentialSecret’ option in
your settings file. Node-RED will then re-encrypt your credentials
file using your chosen key the next time you deploy a change.
———————————————————————

16 Apr 11:06:23 – [info] Server now running at http://127.0.0.1:1880/
16 Apr 11:06:23 – [warn] Encrypted credentials not found
16 Apr 11:06:23 – [info] Starting flows
16 Apr 11:06:23 – [info] Started flows

Result

Done!Node-redがインストールされました。

Play with podman

ここからはAXCF 2152にpodmanを導入する方法を説明します。

Reference Link

PLCNEXT#Firmware update

Check Version

まずpodmanのVersionを確認します。AXCF 2152 2023.0では4.0.3がインストールされています。

root@axcf2152:/# podman version
Client:       Podman Engine
Version:      4.0.3
API Version:  4.0.3
Go Version:   go1.17.13
Git Commit:   62534053086fdeba7b93117e7c4dc6e797835a3e
Built:        Fri Apr  1 15:28:59 2022
OS/Arch:      linux/arm

Error

OverlayがSupportしませんエラーが出ました。

admin@axcf2152:/$ podman info                                       
Error: ‘overlay’ is not supported over overlayfs, a mount_program is required: backing file system is unsupported for this graph driver

Login as root

admin@axcf2152:/$su

mount it

sudo mount –make-rshared /

Check Again

root@axcf2152:/# podman info
host:
  arch: arm
  buildahVersion: 1.24.3
  cgroupControllers:
  – cpuset
  – cpu
  – cpuacct
  – blkio
  – memory
  – devices
  – freezer
  – net_cls
  – net_prio
  – pids
  – rdma

Install Node-red

root@axcf2152:/# podman run -it -p 1880:1880 -v node_red_data:/data –name mynodered nodered/node-red

Error?

/etc/containers/registries.conf が見つかりませんと怒られました。

Error: short-name “nodered/node-red” did not resolve to an alias and no unqualified-search registries are defined in “/etc/containers/registries.conf”

Check Container Files

/etc/containers/の中身をリストアップしてみたら、たしかにregistries.conf がありませんでした。

root@axcf2152:/# ls /etc/containers/*
/etc/containers/containers.conf  /etc/containers/registries.conf
/etc/containers/policy.json /etc/containers/storage.conf

Create Register Files

registries.conf を作りましょう。

root@axcf2152:/# echoe “[registries.search]\nregistries = [‘docker.io’]” | sudo tee /etc/containers/registries.conf
[registries.search]
registries = [‘docker.io’]

Try again

もう一度試したら、Node-redがDownloadできるようになりました。

root@axcf2152:/# podman run -it -p 1880:1880 -v node_red_data:/data –name mynered nodered/node-red
Resolving “nodered/node-red” using unqualified-search registries (/etc/containers/registries.conf)
Trying to pull docker.io/nodered/node-red:latest…

Getting image source signatures
Copying blob a6b45ace95f4 done
Copying blob 67d57a1ee6d6 done
Copying blob fda70e3c8913 done
Copying blob 8a47ee1d653d done
Copying blob 8b31a1a18921 done

Commands

podmanのコマンドは基本Dockerと同じです。

Check Running Container 

root@axcf2152:/# podman ps
CONTAINER ID  IMAGE       COMMAND     CREATED     STATUS      PORTS       NAMES

Check Stopped Container

root@axcf2152:/# podman ps -a
CONTAINER ID  IMAGE                              COMMAND     CREATED        STATUS                                  PORTS                   NAMES
5f5d44a040b4  docker.io/nodered/node-red:latest              3 minutes ago  Exited (130) 55 seconds ago (starting)  0.0.0.0:1880->1880/tcp  mynodered

Stop Container

root@axcf2152:/# podman stop 5f5d44a040b4
5f5d44a040b4

Start Container

root@axcf2152:/# podman start 5f5d44a040b4
5f5d44a040b4

Result

Done!Node-Redはpodman上で稼働しています。

Useful Link

https://nodered.jp/docs/getting-started/docker

https://kemasoft.net/?vm/podman_3.0

https://github.com/containers/podman/issues/9256

https://github.com/containers/buildah/issues/3726

https://www.plcnext.help/te/Service_Components/Using_OCI_containers.htm?rhhlterm=Docker

https://www.plcnext-community.net/forum/#/discussion/3231/node-red-for-plcnext-arm

https://hub.docker.com/r/nodered/node-red-docker

https://docs.rackspace.com/support/how-to/modify-your-hosts-file/

Footer_Basic

Please Support some devices for my blog

Amazon Gift List

Find ME

Twitter:@3threes2
Email:soup01threes*gmail.com (* to @)
YoutubeChannel:https://www.youtube.com/channel/UCQ3CHGAIXZAbeOC_9mjQiWQ

シェアする

  • このエントリーをはてなブックマークに追加

フォローする