# Caching a container

**URL:** <https://forums.balena.io/t/caching-a-container/2698>\
**Category:** Product support\
**Created:** [March 13, 2018, 2:44pm UTC](https://forums.balena.io/t/caching-a-container/2698 "2018-03-13T14:44:41Z")\
**Posts on this page:** 1\
**Showing post:** 11

<div class="post-metadata">

**Author:** ![thgreasi](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/thgreasi/32/454_2.png) [@thgreasi](https://forums.balena.io/u/thgreasi)\
**Post date:** [March 14, 2018, 11:02am UTC](https://forums.balena.io/t/caching-a-container/2698/11 "2018-03-14T11:02:16Z")

</div>

I’m afraid that our builder can’t pull from private repositories at the moment, since it would somehow have to be authenticated against your private repository.

As discussed in this forum thread:

> [@Creating custom base images](https://forums.balena.io/t/creating-custom-base-images/1641/2):
>
> Hey Michael, 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](https://docs.docker.com/docker-for-mac/multi-arch/). binfmt\_misc intercepts system calls to the kernal and uses qemu to emulate. 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](https://docs.resin.io/runtime/resin-base-images/#resin-xbuild-qemu) it’s a script that replicates what binfmt\_misc does without having to touch the host system - m…

a workaround would be to use `resin build` and `resin deploy` locally in order to use you private images.

On the other hand, if the compilation step is independent of the previous steps, you could build a minimal public base image for that and then use multistaged builds, have an extra FROM referencing that base image and only copy the built artifacts. Let me point you to the respective documentation page:

> **[Multi-stage builds](https://docs.docker.com/build/building/multi-stage/)**
>
> Learn about multi-stage builds and how you can use
> them to improve your builds and get smaller images

---

_[View the full topic](https://forums.balena.io/t/caching-a-container/2698)._
