PFC200V3 with MySQL

I am undertaking development on a PFC200V3 (750-8217) using CODESYS 3.5 SP19 (Patch 7). I would like to start storing data to an SQL database and have tried to follow the support materials provided for using MySQL on the PFC200V2 (eCockpit). I obtained a copy of the Docker image “wagoautomation/mysql”, and tried to install on the PFC200V3. The install completed with a warning that the architecture of the image (ARM) was not the same as the host system (Cortex). I can see the image installed, but it continually restarts (see screeshot).

Is it possible to use MySQL with the 750-8217? If so, I would be grateful for any guidance you can offer. Also, while working through the online materials I started to worry about whether use of Docker on the drive of the 750-8217 might cause wear on the associated memory. Is this likely to be an issue, and if so is it possible to move the container to the SD storage?

Many thanks in advance,

Justin.

use mysql:latest mysql - Official Image | Docker Hub. This one in wagoautomation was limited to fit PFC200G2

EDIT:
Autor has PFC200, so he needs to use wagoautomation/mysql or biarms/mysql:5.5

docker run -d --restart always --name mysql -p 3306:3306 --platform=linux/arm/v7 -v /etc/localtime:/etc/localtime -v /media/sd/mysql:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=wago biarms/mysql
docker run -d --restart always --name mysql -p 3306:3306 -v /media/sd/mysql:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=wago -e MYSQL_DATABASE=wago_db wagoautomation/mysql

Many thanks for your response. I obtained the new docker image and tried to install but the install failed due to insufficient drive space. Is there a way for me to increase the available drive space for the Docker image? For additional reference, I will be using the PFC200 with an SD card where I intend to save the MySQL database.

Apologies - I have not worked out how to report screenshots properly on the form

its good to check free space left on the device:
df -h
You can also check if you have any unused volumes:

docker volume ls

to remove volume:

docker volume rm <name>

also check unused images:

docker image ls

and you can delete them:

docker rmi <id or name>

I like to have Portainer for docker management:

you can install this on your device or in other “provisioning” machine and then add “clients” on your devices, so you can deploy container from one place to many controllers :wink:

I am just starting out programming on the PFC200v3 and am still not sure exactly what I am looking at. I had aready run df -h and received the following:

root@PFC200V3-6CB47F:~ df -h
Filesystem                Size      Used Available Use% Mounted on
/dev/root               283.4M    161.4M    102.9M  61% /
devtmpfs                244.0M     12.0K    244.0M   0% /dev
none                    244.5M      4.0K    244.5M   0% /tmp
none                    244.5M         0    244.5M   0% /media
none                      4.0M    280.0K      3.7M   7% /var/log
none                    244.5M    236.0K    244.3M   0% /run
none                    244.5M    236.0K    244.3M   0% /var/run
none                    244.5M         0    244.5M   0% /var/lock
none                    244.5M         0    244.5M   0% /var/tmp
none                    244.5M         0    244.5M   0% /sys/fs/cgroup
/dev/mmcblk0p1           14.8G    160.0K     14.8G   0% /media/3963-3837
/dev/mmcblk1p1           16.0M      3.5M     12.4M  22% /boot/loader
/dev/mmcblk1p9            1.4G    469.7M    914.1M  34% /home
/dev/mmcblk1p6            5.8M     14.0K      5.2M   0% /settings
/dev/mmcblk1p5            5.8M     24.0K      5.2M   0% /log
none                    244.5M    236.0K    244.3M   0% /var/run/netns
/dev/mmcblk1p9            1.4G    469.7M    914.1M  34% /home/docker

I had thought that the docker might be in the volume /home/docker, but that does not seem likely given that the image pull failed (I don’t think the image is anything near 600M).

I also started by confirming that there were no pre-existing docker images.

Following your advice, I checked for unused docker volumes and found one which I deleted. I then attempted to install the sql image again, which failed with the same error message:

root@PFC200V3-6CB47F:/home/dockerimages docker load -i mysql_image.docker
1355aaece24a: Loading layer [==================================================>]   49.5MB/49.5MB
e20ba2d8994b: Loading layer [==================================================>]     888B/888B
6e314af29b8d: Loading layer [==================================================>]    983kB/983kB
3d38444e5103: Loading layer [==================================================>]  6.819MB/6.819MB
9376bd9ad595: Loading layer [==================================================>]  2.602kB/2.602kB
62b9d6d47b8f: Loading layer [==================================================>]     340B/340B
0bcfc46fef17: Loading layer [==================================================>]  49.27MB/49.27MB
5170a12404a2: Loading layer [==================================================>]     325B/325B
cd0f83389997: Loading layer [======================================>            ]  129.2MB/168.9MB
write /usr/lib/mysqlsh/libjitexecutor.so: no space left on device

Is there a way to increase space on /user/lib ? I have little experience with this - could /user/lib be subject to a maximum file size (less than 130MB) ?

Otherwise, portainer looks promising - many thanks for the tip!

hm, something looks wrong, because you dont have full disk space, look at mine - Ive got 16Gb free space in home catalog:

Hm, are you sure you dont boot from sd card and work in sd card? Try to take out the SD card

I think the image size for SQL is about 250 MB, but I’m not sure how much total space it needs for the install process itself. Since you have a PFC200 (not a PFC300 like shown by WagoDamRud), the ~900M free you have in /home/docker isn’t surprising.

You can move the directory for Docker from internal flash to the SD card using the method shown on page 12 of this Docker Quickstart: How To: Getting Started with Docker

But first, I fully agree with WagoDamRud, make sure you are not booting the PFC200 from a SD card firmware image!

The 750-8217 is listed with the following specs:

Main memory (RAM)	512MB
Internal memory (flash)	4096MB
Non-volatile hardware memory	128kbyte
Program memory	32 MB
Data memory	128 MB

I think the df -h command output that I report above approximately adds to 4GB, so that might be the problem. Booting without the SD card installed didn’t change anything. All of the PFC200 units look like they have 4GB of flash memory - not sure what PLC you are using (16.7G would be brilliant).

I will try to move the directory for Docker as suggested by @AdamReeve and get back to you - if that works, then it looks like the PFC200 has too little flash to accommodate MySQL (which is a pain).

Yes, I was talking about the PFC300 the whole time, sorry for the confusion! Its PFC200 G2, so you can’t use official mysql image, because its only for x64 proccessors!

You are right - we have an ARMv7 (32 bit) processor. So that leaves the question: is it possible to use MySQL (or any SQL) with the PFC200G2?

It is possible, format your SD card and mv docker to SD:
WAGO/docker-ipk: This repo contains static linked binaries of docker ce packed in linux ipk format.

then try this one:

docker run -d --restart always --name mysql -p 3306:3306 --platform=linux/arm/v7 -v /etc/localtime:/etc/localtime -v /media/sd/mysql:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=wago biarms/mysql
docker run -d --restart always --name mysql -p 3306:3306 -v /media/sd/mysql:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=wago -e MYSQL_DATABASE=wago_db wagoautomation/mysql

@WagoDamRud - I tried the wagoautomation/mysql container on the first go, and this resulted in me comming to this forum (given that I have an ARMv7, I guess the image was built using the Cortex processor). I will try the first option that you note above and get back to you with results.

Many thanks once again, Justin

Unfortunately, still no luck: the image’s platform (linux/amd64) doesn’t match the host platform (linux/arm/v7):

root@PFC200V3-6CB47F:~ cd /home/dockerimages
root@PFC200V3-6CB47F:/home/dockerimages docker volume ls
DRIVER    VOLUME NAME
root@PFC200V3-6CB47F:/home/dockerimages docker images
REPOSITORY   TAG       IMAGE ID   CREATED   SIZE
root@PFC200V3-6CB47F:/home/dockerimages docker load -i mysql_image.docker
f2fa9f4cf8fd: Loading layer [==================================================>]  70.69MB/70.69MB
48dc77435ad5: Loading layer [==================================================>]  72.66kB/72.66kB
3da511183950: Loading layer [==================================================>]     163B/163B
683157e9529f: Loading layer [==================================================>]  1.836kB/1.836kB
f8af48bb4e7d: Loading layer [==================================================>]  1.638MB/1.638MB
cc5b4820bbfc: Loading layer [==================================================>]     149B/149B
12dda2505cdb: Loading layer [==================================================>]  694.5kB/694.5kB
f12518219156: Loading layer [==================================================>]  29.17MB/29.17MB
e2f8c6d07b2a: Loading layer [==================================================>]  2.174kB/2.174kB
6a07d221b135: Loading layer [==================================================>]   2.21kB/2.21kB
f077a82947e3: Loading layer [==================================================>]     290B/290B
ac464afc27d8: Loading layer [==================================================>]  1.587kB/1.587kB
Loaded image: biarms/mysql:5.5
root@PFC200V3-6CB47F:/home/dockerimages docker images
REPOSITORY     TAG       IMAGE ID       CREATED       SIZE
biarms/mysql   5.5       9a6b109abe1b   5 years ago   304MB
root@PFC200V3-6CB47F:/home/dockerimages docker run -d --restart always --name mysql -p 3306:3306 -v /etc/localtime:/etc/localtime -v /media/sd/mysql:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=<user password> -e MYSQL_PASSWORD=<user password> -e MYSQL_USER=<user name> -e MYSQL_DATABASE=<database name> biarms/mysql:5.5
WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm/v7) and no specific platform was requested
f879bdba5be32446d22e3e92802b235f041f2e71208934d71b65feeb2c8f9b4a
root@PFC200V3-6CB47F:/home/dockerimages docker ps
CONTAINER ID   IMAGE              COMMAND                  CREATED         STATUS                          PORTS     NAMES
f879bdba5be3   biarms/mysql:5.5   "/usr/local/bin/dock…"   2 minutes ago   Restarting (1) 11 seconds ago             mysql

Note in the above that the terms in <> were entered with text values. I guess I need to find a docker image for MySQL that is built for ARMv7. Would SQLite be easier to integrate?

Some problems with manifest. We need to add:

--platform=linux/arm/v7

So in summary, you can use this run command:

docker run -d --restart always --name mysql -p 3306:3306 --platform=linux/arm/v7 -v /etc/localtime:/etc/localtime -v /media/sd/mysql:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=wago biarms/mysql

This time I checked if its working, it is :wink:

@WagoDamRud - entering the command that you suggest returns an error on my system:

<:3306 --platform=linux/arm/v7 -v /etc/localtime:/etc/localtime -v /media/sd/mysql:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=wago biarms/mysql
Unable to find image 'biarms/mysql:latest' locally
docker: Error response from daemon: Get "https://registry-1.docker.io/v2/": dial tcp: lookup registry-1.docker.io on [::1]:53: dial udp [::1]:53: connect: cannot assign requested address.
See 'docker run --help'.

I think the reason is that the device does not have access to the internet, and the image is designed to check this. I tried to provide access to the internet by attaching the PLC to an open network, but that didn’t help. I should also note that attempting to add reference to the specific version of a locally saved docker image also failed. This seems to be the case whenever you add the –platform option to the command.

After a fair bit of trial and error, the docker image now seems to be up and running. I ended up having to connect the PFC200 to the internet after which it was possible to run the command:

docker run -d --restart always --platform=linux/arm/v7 --name mysql -p 3306:3306 -v /etc/localtime:/etc/localtime -v /media/sd/mysql:/var/lib/mysql:rw -e MYSQL_ROOT_PASSWORD=<database password> -e MYSQL_PASSWORD=<database password> -e MYSQL_USER=<database user> -e MYSQL_DATABASE=<database name> biarms/mysql:5

I was not able to install the container without internet access.

Another issue that I am finding is that the docker container fails to re-connect to the SD card folder after a reboot. Sometimes it will re-connect if I remove and then re-insert the SD card, but in those cases it will then clear the existing content and start with an empty database. I currently have it working on the internal flash memory, which seems to be functioning as expected. For reference, I have been using a Sandisk Extreme card for testing which I formatted using the WBM tool to a single volume named sd in FAT format.