Mender Client inside Docker container

Hello,

Would it be possible to run the Mender client inside a docker container that runs in privileged mode ? The container could access /dev and other requirements. Mender would on an x86 board with grub as bootloader and in standalone mode.

Have someone already tested it?

Thanks

Hi @Dewey, I’m not aware of anyone having tried this but as long as the client has block-level access to the device nodes, proper mounts of /usr/share/mender, and the ability to run fw_printenv and fw_setenv, I see no reason it wouldn’t work. Please let us know if you try it, and what requirements the container must have if there are more than listed above.
Drew

1 Like

Sorry for the pretty long delay, I’m currently trying to run Mender in a container. The system image is Yocto based.

I created the following Dockerfile:

FROM ubuntu:18.04
RUN apt-get update
RUN apt-get upgrade
RUN apt-get install lzma
COPY mender /usr/bin/

So that Mender has all the dependencies that it needs.
When running ldd on the Mender binaries, it seems ok:

root@6a97c6b3c079:/# ldd /usr/bin/mender
linux-vdso.so.1 (0x00007fff65b84000)
liblzma.so.5 => /lib/x86_64-linux-gnu/liblzma.so.5 (0x00007fbfa5fa0000)
libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007fbfa5d81000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fbfa5990000)
libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007fbfa578c000)
/lib/ld-linux-x86-64.so.2 => /lib64/ld-linux-x86-64.so.2 (0x00007fbfa61c6000)

In addition the file has the right permission:

root@6a97c6b3c079:/# ls -lash /usr/bin/mender
7.8M -rwxr-xr-x 1 root root 7.8M Jun 25 11:21 /usr/bin/mender

As for the access to the host device I shared the following directory:

--privileged -v /dev:/dev -v /usr/share/mender:/usr/share/mender -v /data:/data -v /etc/mender:/etc/mender

However, when calling “./mender”, I get the following error:

bash: ./mender: No such file or directory

To get the mender binary, I simply copied it from the host device to the docker filesystem, may it be the problem ? Should I recompile the client from sources ?

Is it the executable bit set inside the Docker container?

Yes, I did it that way (inside the container) and it did not resolve the problem:

root@1152740f5ef8:/usr/bin# chmod +x mender
root@1152740f5ef8:/usr/bin# ls -lash mender
7.8M -rwxr-xr-x 1 root root 7.8M Jun 25 11:21 mender
root@1152740f5ef8:/usr/bin# ./mender
bash: ./mender: No such file or directory

Running strace does not provide more information:

root@1152740f5ef8:/usr/bin# strace ./mender
execve("./mender", ["./mender"], 0x7fff3b10c3d0 /* 9 vars */) = -1 ENOENT (No such file or directory)
fstat(2, {st_mode=S_IFCHR|0620, st_rdev=makedev(136, 1), ...}) = 0
write(2, "strace: exec: No such file or di"..., 40strace: exec: No such file or directory
) = 40
getpid()                                = 58
exit_group(1)                           = ?
+++ exited with 1 +++