# How to build my custom base image?

**URL:** <https://forums.balena.io/t/how-to-build-my-custom-base-image/933>\
**Category:** Product support\
**Created:** [May 10, 2017, 10:31am UTC](https://forums.balena.io/t/how-to-build-my-custom-base-image/933 "2017-05-10T10:31:53Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![benoitguigal](https://avatars.discourse-cdn.com/v4/letter/b/46a35a/32.png) [@benoitguigal](https://forums.balena.io/u/benoitguigal)\
**Post date:** [May 10, 2017, 10:31am UTC](https://forums.balena.io/t/how-to-build-my-custom-base-image/933/1 "2017-05-10T10:31:53Z")

</div>

I would like to create a base image for my project. The image would be based on `resin/raspberry-pi2-node6`, on top of which I would install some libraries. Example of Dockerfile:

```auto
FROM resin/raspberry-pi2-node:6 

COPY qemu-arm-static /usr/bin/

RUN apt-get update && apt-get install -y tar wget git && rm -rf /var/lib/apt/lists/*

```

`docker build -t mycompany/raspberry-pi2`  
`docker push mycompany/raspberry-pi2`

I would then be able to base my project on this image

```auto
FROM mycompany/raspberry-pi2 

```

When I tried to build the image on my local Linux, I got the error

```auto
exec format error
[8] System error: exec format error

```

I guess this is because I am trying to build the image from a non ARMv6 architecture. Is it possible to emulate this architecture on my local machine or should I build from a Raspberry Pi 2 ?

Thanks for your help

---

<div class="post-metadata">

**Author:** ![pcarranzav](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/pcarranzav/32/94_2.png) [@pcarranzav](https://forums.balena.io/u/pcarranzav)\
**Post date:** [May 10, 2017, 10:22pm UTC](https://forums.balena.io/t/how-to-build-my-custom-base-image/933/2 "2017-05-10T22:22:21Z")

</div>

Hi @benoitguigal ! Maybe this will help you: [https://resin.io/blog/building-arm-containers-on-any-x86-machine-even-dockerhub](https://resin.io/blog/building-arm-containers-on-any-x86-machine-even-dockerhub) (though building on a Pi will work too, only it’ll probably be slower)

---

<div class="post-metadata">

**Author:** ![pcarranzav](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/pcarranzav/32/94_2.png) [@pcarranzav](https://forums.balena.io/u/pcarranzav)\
**Post date:** [May 10, 2017, 10:38pm UTC](https://forums.balena.io/t/how-to-build-my-custom-base-image/933/3 "2017-05-10T22:38:34Z")

</div>

In particular, from that blogpost, I think all you need to do is:

```auto
mount binfmt_misc -t binfmt_misc /proc/sys/fs/binfmt_misc  
echo ':arm:M::\x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x28\x00:\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff:/usr/bin/qemu-arm-static:' > /proc/sys/fs/binfmt_misc/register  

```

And then you don’t need to copy qemu-arm-static, everything should work out of the box (as our base images already have it).

---

<div class="post-metadata">

**Author:** ![benoitguigal](https://avatars.discourse-cdn.com/v4/letter/b/46a35a/32.png) [@benoitguigal](https://forums.balena.io/u/benoitguigal)\
**Post date:** [May 12, 2017, 10:10pm UTC](https://forums.balena.io/t/how-to-build-my-custom-base-image/933/4 "2017-05-12T22:10:41Z")

</div>

It works like a charm ! Thank you

---

<div class="post-metadata">

**Author:** ![hedss](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/hedss/32/210_2.png) [@hedss](https://forums.balena.io/u/hedss)\
**Post date:** [July 23, 2018, 2:32pm UTC](https://forums.balena.io/t/how-to-build-my-custom-base-image/933/8 "2018-07-23T14:32:34Z")

</div>

Hi,

Yes, you will need to build any custom base image and then make it publicly available on Dockerhub for our Builder to be able to use it when building Applications.

We have a small article on how to do this [here](https://docs.resin.io/reference/base-images/custom-docker-base-images/).

Hope this helps!
