Creating custom base images

raspberrypi3
docker

#1

I try to create my own base images and I have one question and two problems regarding that.

  1. A question, out of idle curiosity: how does Dockerfile with FROM resin/raspberrypi3-debian manages to build on a mac? I was really surprised that it worked on my machine (because arm and x86 are quite different beasts).

  2. Why the same Dockerfile that worked locally fails to build an image on docker cloud services (both hub and cloud):

Building in Docker Cloud's infrastructure...
Cloning into '.'...
Warning: Permanently added the RSA host key for IP address '104.192.143.3' to the list of known hosts.
Reset branch 'master'
Your branch is up-to-date with 'origin/master'.
KernelVersion: 4.4.0-87-generic
Arch: amd64
BuildTime: 2017-03-28T19:26:53.326478373+00:00
ApiVersion: 1.27
Version: 17.03.1-ee-2
MinAPIVersion: 1.12
GitCommit: ad495cb
Os: linux
GoVersion: go1.7.5
Starting build of index.docker.io/vasin/vs-player:latest...
Step 1/7 : FROM resin/raspberrypi3-debian
---> 31724eed925c
Step 2/7 : RUN apt-get update && apt-get install -yq cmake build-essential
---> Running in 90170e50105f
standard_init_linux.go:178: exec user process caused "exec format error"
Removing intermediate container 90170e50105f
The command '/bin/sh -c apt-get update && apt-get install -yq cmake build-essential' returned a non-zero code: 1
ERROR: Build failed: The command '/bin/sh -c apt-get update && apt-get install -yq cmake build-essential' returned a non-zero code: 1
ERROR: Build failed with exit code 2
ERROR: Build in 'master' (7b8c52f1) failed in 0:01:45

Are there any workarounds? I’d prefer to just push code of my base image to repository and not to build and push docker image to docker cloud manually after that.

I’ve noticed that https://hub.docker.com/r/resin/raspberrypi3-debian/ is also not auto-built, so I suppose resin.io team has the same problem.

  1. How can I pull a private base image from Docker hub for resin.io device? I was able to use a public image for that, now how do I tell resin my docker credentials?

#2

Hey Michael,

  1. All resin-base images have a qemu binary which allows them to run on any host that has binfmt_misc setup and docker for mac does. binfmt_misc intercepts system calls to the kernal and uses qemu to emulate.

  2. I’ve only ever built custom images locally, but it is possible to build them on CI servers if you use a resin image as a base, this is because there is a tool called Resin-xbuild it’s a script that replicates what binfmt_misc does without having to touch the host system - more info here. You do however need to tell the tool which calls to intercept.

RUN [ "cross-build-start" ]
RUN apt-get install ...
RUN [ "cross-build-end" ]

Example here.

https://hub.docker.com/r/resin/raspberrypi3-debian/ is built on a custom CI server, so as far as I know we don’t need this tool, @nghiant2710 could you confirm?

  1. We currently don’t support build environment variables so there is no way to keep secrets in your build atm. A good work around is to build the image locally with our cli.
    The two commands you’ll need are:

This is a little out of my wheel house so I’ll have to ask @nghiant2710 our base image expert to make sure everything I’ve said is up to date and accurate. I hope that explains things a little.


Caching a container