Howto create emoncms docker images in different arch

okay - a quick how to make an emoncms container that are in different arch-- this took most of the day to figure out as the information is very sparse and far between
install docker on your computer

basically follow the information found here for installing docker

this will only give you your basic compiling needs either i386 or amd64 for most

to beable to build you have to install qemu and and the other arch you wish to compile for in my case it was arm

so you install qemu and qemu-system-arm

apt install qemu qemu-system-arm

now you need to update docker using the new binfm tag
obtained from here

then run this with newest tag

sudo docker run --rm --privileged docker/binfmt:a7996909642ee92942dcd6cff44b9b95f08dad64

then run this to see if qemu is running

$ cat /proc/sys/fs/binfmt_misc/qemu-aarch64 

and it out put something like this

 interpreter /usr/bin/qemu-aarch64 
flags: OCF 
offset 0 
magic 7f454c460201010000000000000000000200b7

now you can check what architectures docker supports

docker buildx ls

and hopefully it outputs something like this

default    running 20.10.21 linux/amd64, linux/386, linux/arm64, linux/riscv64, linux/ppc64le, linux/s390x, linux/arm/v7, linux/arm/v6

now you can try to build your emoncms container

first setup emoncms

git clone
cd emoncms-docker

now prepare buildx

docker buildx create --name mybuilds
docker buildx use mybuilds
docker buildx inspect --bootstrap

now to create different archs

 docker buildx build --platform linux/amd64 -t emoncms-amd64 --load .
 docker buildx build --platform linux/arm64 -t emoncms-arm64 --load .
 docker buildx build --platform linux/arm/v7 -t emoncms-arm32 --load .

or to build and push to your docker hub

docker buildx build --push --platform linux/arm/v7,linux/arm64/v8,linux/amd64`  --tag <user name>/emoncms:latest .

well hopefully all goes well and you have built working emoncms containers for different architectures

edit: so I tried on fresh install just to see if it works from a fresh install this method. so some weirdness appeared it would not work until qemu and qemu-system-arm was installed but after reboot it stop working until qemu and qemu-system-arm was removed ( including autoremove) then it would work after each reboot. but slightly less was removed then installed so I guess it was missing a few essential file to make it work on flavour of linux . plus docker-desktop had to be install to allow upload to docker-hub

1 Like

Looks good.

Does this pick up the latest version of Emoncms?

Is it self contained (some version tried needed an external MSQL for instance).

Hi Brian

Stephen’s approach doesn’t really determine if it’s self-contained or not.

Although he’s pointed to emoncms-docker, you could use this technique to build any Docker containers you wanted.

The EmonCMS team’s Docker does indeed have external dependencies:

We have taken a multi-container approach with php-apache running in one container and the MYSQL database running in another. The containers are linked using docker-compose.

This is quite common. Once you’ve taken the hit of using Docker, it’s somewhat easy to add other Docker containers. In fact my setup has 34 containers running which includes EmonCMS, my weather station, mail servers, web servers, databases and so on.

If you want something that uses minimal resources then you would be better off in-lining all the things into a single container. That’s not idiomatic in Docker because you will tangle their environments with each other and trip up on weird things such as programs needing incompatible versions of some library.

BTW Nice work Stephen.

Yes appreciate all of that, I was just wondering what Stephen had ended up with.

Multi container; personally, I don’t like Docker for exactly this reason. I’m a PVE fan - a single LXC container has it all in one place and the automated backups of Proxmox are a dream. Trying to backup a multiple container setup of Emoncms so they all align in time, must be tricky.

It’s worse than tricky, multi-locations state backups are impossible without stopping-the-world or having some exciting sync code on startup that agrees where they got to.

Luckily we don’t have to do that because the authoritative state is in the mariadb container and I just back that up and I’m safe.

Here’s what I do. In fact I do this for all my databases so I just re-used that logic.

docker run \
-d \
-v /local_backups/most_recent:/var/backup/most_recent \
-v /local_scripts/ \
--link ${MARIA_DB}:db \
-w /var/backup/ \
-e DB_DBNAME=emoncms \
--entrypoint="bash" \
mariadb "/var/backup/"

There’s also a similar bit of saucy logrotate going on to keep a history.

Hopefully you back up the data files too :wink:

Still the one stop PVE method from the UI can’t be beaten IMHO. It even saves it off device as well :slight_smile: