# Push docker image directly to docker repository

**URL:** <https://forums.balena.io/t/push-docker-image-directly-to-docker-repository/14775>\
**Category:** Product support\
**Tags:** support, docker\
**Created:** [June 11, 2019, 1:01pm UTC](https://forums.balena.io/t/push-docker-image-directly-to-docker-repository/14775 "2019-06-11T13:01:38Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![megger](https://avatars.discourse-cdn.com/v4/letter/m/7c8e57/32.png) [@megger](https://forums.balena.io/u/megger)\
**Post date:** [June 11, 2019, 1:01pm UTC](https://forums.balena.io/t/push-docker-image-directly-to-docker-repository/14775/1 "2019-06-11T13:01:38Z")

</div>

we would like to use our locally built docker images to be used because building the docker image with the balena base image on the balena build server is not an option currently.  
there seems to be a way to do this with the balena cli, but before installing a cli tool I would like to know if there are other options.

Is it possible to put the docker image in a git with the docker-compose.yml push that to the balena git repository and it will automatically generate a working balena docker image? (Please note, that the saved docker image will not be based on any of the balena base images.)  
Thanks  
Michael

---

<div class="post-metadata">

**Author:** ![richbayliss](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/richbayliss/32/1054_2.png) [@richbayliss](https://forums.balena.io/u/richbayliss)\
**Post date:** [June 11, 2019, 1:14pm UTC](https://forums.balena.io/t/push-docker-image-directly-to-docker-repository/14775/2 "2019-06-11T13:14:10Z")

</div>

Hi,

There is no requirement to use a Balena base-image; they are provided as a convenience for you if you wish. You can use the `git push` mechanism to push your code/docker files to our builder, where they will be built and registered to your application in our cloud docker-registry.

Does this help you at all?

---

<div class="post-metadata">

**Author:** ![megger](https://avatars.discourse-cdn.com/v4/letter/m/7c8e57/32.png) [@megger](https://forums.balena.io/u/megger)\
**Post date:** [June 11, 2019, 1:17pm UTC](https://forums.balena.io/t/push-docker-image-directly-to-docker-repository/14775/4 "2019-06-11T13:17:52Z")

</div>

Any chance to get this working with a locally built docker image (not a Dockerfile)  
the image is available on [hub.docker.com](http://hub.docker.com) (although private)

---

<div class="post-metadata">

**Author:** ![richbayliss](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/richbayliss/32/1054_2.png) [@richbayliss](https://forums.balena.io/u/richbayliss)\
**Post date:** [June 11, 2019, 1:29pm UTC](https://forums.balena.io/t/push-docker-image-directly-to-docker-repository/14775/5 "2019-06-11T13:29:49Z")

</div>

You can use the `balena-cli` tool to `balena push` and include a `--registry-secrets` argument, pointing to a file with your Dockerhub credentials in it.

Or, if this is for development, you can export `DOCKER_HOST` variable to be `tcp://ip.of.device:2375` if the device is a development image; this let’s you build on the device, or `docker pull` from dockerhub (after logging in)

Could you clarify why the cloud builder route is no possible, as it would help us to advise you better. Thanks.

---

<div class="post-metadata">

**Author:** ![megger](https://avatars.discourse-cdn.com/v4/letter/m/7c8e57/32.png) [@megger](https://forums.balena.io/u/megger)\
**Post date:** [June 11, 2019, 1:36pm UTC](https://forums.balena.io/t/push-docker-image-directly-to-docker-repository/14775/7 "2019-06-11T13:36:03Z")

</div>

we would like to use an existing docker image without any modifications.

The cloud builder is not an option right now because we would have to upload all our build files to your git repository and it is not clear who has access to this repository. Also all tests are performed on our docker image, if we let you build the image, we have to run all the tests twice.

---

<div class="post-metadata">

**Author:** ![megger](https://avatars.discourse-cdn.com/v4/letter/m/7c8e57/32.png) [@megger](https://forums.balena.io/u/megger)\
**Post date:** [June 11, 2019, 1:58pm UTC](https://forums.balena.io/t/push-docker-image-directly-to-docker-repository/14775/8 "2019-06-11T13:58:14Z")

</div>

ideally we would like to upload or push a docker-image, our config file (not the balena config) and a docker-compose-file.  
The docker-compose file would have to mount the config file which is an xml file. The config file would be different for every device in the field. I am not sure yet, if this is the ideal set-up or even possible when using balena, but this is how we deploy our containers right now.

---

<div class="post-metadata">

**Author:** ![megger](https://avatars.discourse-cdn.com/v4/letter/m/7c8e57/32.png) [@megger](https://forums.balena.io/u/megger)\
**Post date:** [June 11, 2019, 2:12pm UTC](https://forums.balena.io/t/push-docker-image-directly-to-docker-repository/14775/9 "2019-06-11T14:12:07Z")

</div>

so I read through the cli documentation and found the `balena deploy` command.  
The question now is, how to add the `docker-compose.yml` and our custom resource file.

---

<div class="post-metadata">

**Author:** ![richbayliss](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/richbayliss/32/1054_2.png) [@richbayliss](https://forums.balena.io/u/richbayliss)\
**Post date:** [June 11, 2019, 2:27pm UTC](https://forums.balena.io/t/push-docker-image-directly-to-docker-repository/14775/10 "2019-06-11T14:27:11Z")

</div>

So if you use `balena push` in a directory containing a `docker-compose.yml` having a service which references your image, and also a `registry-secrets.yml` with your dockerhub credentials, then this image will be pulled onto our backend, and pushed to your device untouched. This would get your service on the device.

Regarding the XML config file - you would have to make this a device-specific environment variable and have your entrypoint expand it into the filesystem.

---

<div class="post-metadata">

**Author:** ![megger](https://avatars.discourse-cdn.com/v4/letter/m/7c8e57/32.png) [@megger](https://forums.balena.io/u/megger)\
**Post date:** [June 11, 2019, 2:48pm UTC](https://forums.balena.io/t/push-docker-image-directly-to-docker-repository/14775/11 "2019-06-11T14:48:03Z")

</div>

thank you for the answers so far!

our xml config file is 1200 lines and it is signed. Storing this in an environment variable and expanding during launch will most likely break the signature.

Are there any other options to add device specific files? If so, please let me know.

---

<div class="post-metadata">

**Author:** ![richbayliss](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/richbayliss/32/1054_2.png) [@richbayliss](https://forums.balena.io/u/richbayliss)\
**Post date:** [June 11, 2019, 2:50pm UTC](https://forums.balena.io/t/push-docker-image-directly-to-docker-repository/14775/12 "2019-06-11T14:50:37Z")

</div>

You could `base64` the file; this should keep its format when decoding - but I agree it wouldn’t be a very pretty process.
