# Deploy a pre-built image into balena using local mode

**URL:** <https://forums.balena.io/t/deploy-a-pre-built-image-into-balena-using-local-mode/56058>\
**Category:** balenaOS\
**Tags:** docker\
**Created:** [January 10, 2020, 10:40pm UTC](https://forums.balena.io/t/deploy-a-pre-built-image-into-balena-using-local-mode/56058 "2020-01-10T22:40:55Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![gh\_laylapezeshkmher](https://avatars.discourse-cdn.com/v4/letter/g/8c91f0/32.png) [@gh\_laylapezeshkmher](https://forums.balena.io/u/gh_laylapezeshkmher)\
**Post date:** [January 10, 2020, 10:40pm UTC](https://forums.balena.io/t/deploy-a-pre-built-image-into-balena-using-local-mode/56058/1 "2020-01-10T22:40:55Z")

</div>

Im trying to Deploy a pre-built image in to balena using local mode. The image is inside the dockerhub. After pulling the image into my computer and using balena deploy command:  
balena deploy MyApp MyImage  
in the command line, I get the following errors. I have to mention that I am using the latest balena cli version (11.21.0)! There is a message indication Unauthorized and can not access application. Im assuming I don’t have the right to deploy to balena.

 ![Screen Shot 2020-01-10 at 12.31.09 PM](https://global.discourse-cdn.com/balena/original/2X/b/be0d3b63864843838612ed8911a0606a3009574f.png)

Appreciate any suggestion of how to fix this issue and to deploy my image into my app in balena.

---

<div class="post-metadata">

**Author:** ![dt-rush](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/dt-rush/32/1405_2.png) [@dt-rush](https://forums.balena.io/u/dt-rush)\
**Post date:** [January 11, 2020, 12:30am UTC](https://forums.balena.io/t/deploy-a-pre-built-image-into-balena-using-local-mode/56058/2 "2020-01-11T00:30:56Z")

</div>

Thanks for taking the time to provide enough information to get a handle on what might be happening. Unauthorized is either, the application doesn’t exist and we’re folding all 404’s into 403’s to prevent war-dialing (typo in app name? We can’t see the original deploy command in the screenshot).

I assume as a sanity check you have run `balena login` [1]?

[1] [https://github.com/balena-io/balena-cli-masterclass#12-authentication](https://github.com/balena-io/balena-cli-masterclass#12-authentication)

---

<div class="post-metadata">

**Author:** ![gh\_laylapezeshkmher](https://avatars.discourse-cdn.com/v4/letter/g/8c91f0/32.png) [@gh\_laylapezeshkmher](https://forums.balena.io/u/gh_laylapezeshkmher)\
**Post date:** [January 13, 2020, 6:19pm UTC](https://forums.balena.io/t/deploy-a-pre-built-image-into-balena-using-local-mode/56058/8 "2020-01-13T18:19:52Z")

</div>

[![](https://global.discourse-cdn.com/balena/original/2X/a/a13959d96a61f073a0b8971f581603053b092604.png) Balena Deploy problem](https://docs.google.com/a/skycatch.com/document/d/1ZrQ8i3VoVLA0BAnGKJBcUoGn0r1sCSE7zcM-fDJM3tQ/edit?usp=drive_web)

---

<div class="post-metadata">

**Author:** ![pdcastro](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/pdcastro/32/1264_2.png) [@pdcastro](https://forums.balena.io/u/pdcastro)\
**Post date:** [January 14, 2020, 1:11am UTC](https://forums.balena.io/t/deploy-a-pre-built-image-into-balena-using-local-mode/56058/10 "2020-01-14T01:11:28Z")

</div>

Thank you for sharing the additional details @gh_laylapezeshkmher. I’ve engaged the team to try and reproduce this issue and we will get back to you shortly.

---

<div class="post-metadata">

**Author:** ![gh\_laylapezeshkmher](https://avatars.discourse-cdn.com/v4/letter/g/8c91f0/32.png) [@gh\_laylapezeshkmher](https://forums.balena.io/u/gh_laylapezeshkmher)\
**Post date:** [January 14, 2020, 1:41am UTC](https://forums.balena.io/t/deploy-a-pre-built-image-into-balena-using-local-mode/56058/13 "2020-01-14T01:41:32Z")

</div>

Thank you! I think we know what the issue is. Currently, we are using not the updated BalenaOS. We are still using the 2.9 version. We need to upgrade the Balena OS. Also we need to change the app type from classic to another type. Once we make these changes, I will be able to execute the balena deploy command.

Layla

---

<div class="post-metadata">

**Author:** ![gelbal](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/gelbal/32/1109_2.png) [@gelbal](https://forums.balena.io/u/gelbal)\
**Post date:** [January 14, 2020, 10:50am UTC](https://forums.balena.io/t/deploy-a-pre-built-image-into-balena-using-local-mode/56058/14 "2020-01-14T10:50:39Z")

</div>

Hello Layla, thank you for the update. Please let us know how it goes with the application type change as well as OS upgrade.

I see that @pdcastro is actively looking into this. So he’d give further updates when he makes progress. Meanwhile, please ping us of any comments or questions.

---

<div class="post-metadata">

**Author:** ![pdcastro](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/pdcastro/32/1264_2.png) [@pdcastro](https://forums.balena.io/u/pdcastro)\
**Post date:** [January 14, 2020, 1:13pm UTC](https://forums.balena.io/t/deploy-a-pre-built-image-into-balena-using-local-mode/56058/16 "2020-01-14T13:13:59Z")

</div>

@gh_laylapezeshkmher, the investigation so far suggests that the problem is that the application **owner** username needs to be prefixed to the application name in the format `owner/appname`. I assume you are not the owner of the `Edge1CI` application: I assume you have the Developer role as an application member. You can use the web dashboard to open the Members tab/panel for the application, where you will find the owner’s username. Then, instead of running the following command:

```auto
balena deploy Edge1CI skycatch/docker-edge1:arm

```

Run it with the owner prefix:

```auto
balena deploy owner/Edge1CI skycatch/docker-edge1:arm

```

where `owner` is the username you found for the application owner in the web dashboard. **This is only required for ‘Classic’ and ‘Legacy’ application types _and_ when the user running the command is not owner,** which is why you would not have had the same problem with non-legacy apps like ‘Microservices’, ‘Essentials’ or ‘Starter’.

Let us know if this works! I have created a CLI issue for this to be better documented, for the error message to be improved and perhaps for the prefix requirement to be removed altogether:

- [https://github.com/balena-io/balena-cli/issues/1568](https://github.com/balena-io/balena-cli/issues/1568)

---

<div class="post-metadata">

**Author:** ![gh\_laylapezeshkmher](https://avatars.discourse-cdn.com/v4/letter/g/8c91f0/32.png) [@gh\_laylapezeshkmher](https://forums.balena.io/u/gh_laylapezeshkmher)\
**Post date:** [January 14, 2020, 7:17pm UTC](https://forums.balena.io/t/deploy-a-pre-built-image-into-balena-using-local-mode/56058/18 "2020-01-14T19:17:19Z")

</div>

Hello, thank you! I used the owner’s user name as a prefix and it worked! However, I have to get the image from a private repository in the dockerhub and I used the following command which failed:  
balena deploy owner’susername/Edge1CI skycatch/docker-edge1:arm --registry-secrets registry-secrets.yml

Inside the registry-secrets I have the user and password for the dockerhub. Also registry-secrets.yml is defined in the same folder as I am executing the deploy command therefore, I am not including the path to registry-secrets.yml

can you please confirm.

thank you!

---

<div class="post-metadata">

**Author:** ![gh\_laylapezeshkmher](https://avatars.discourse-cdn.com/v4/letter/g/8c91f0/32.png) [@gh\_laylapezeshkmher](https://forums.balena.io/u/gh_laylapezeshkmher)\
**Post date:** [January 14, 2020, 7:20pm UTC](https://forums.balena.io/t/deploy-a-pre-built-image-into-balena-using-local-mode/56058/19 "2020-01-14T19:20:15Z")

</div>

I have defined the registry-secrets.yml as follows:  
’ ': # Use the empty string to refer to the Docker Hub

username: mydockeruser

password: mydockerpassword

---

<div class="post-metadata">

**Author:** ![jimsynz](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/jimsynz/32/4663_2.png) [@jimsynz](https://forums.balena.io/u/jimsynz)\
**Post date:** [January 14, 2020, 7:39pm UTC](https://forums.balena.io/t/deploy-a-pre-built-image-into-balena-using-local-mode/56058/20 "2020-01-14T19:39:34Z")

</div>

Hi there. It looks like we lost some formatting there. According to [the documentation I could find](https://www.balena.io/docs/learn/develop/local-mode/#using-a-private-docker-registry) you need to set the registry URL explicitly. Can you try changing your `registry-secrets.yml` as below?

```auto
'https://index.docker.io/v2/':
  username: mydockeruser
  password: mydockerpassword

```

---

<div class="post-metadata">

**Author:** ![pdcastro](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/pdcastro/32/1264_2.png) [@pdcastro](https://forums.balena.io/u/pdcastro)\
**Post date:** [January 14, 2020, 8:49pm UTC](https://forums.balena.io/t/deploy-a-pre-built-image-into-balena-using-local-mode/56058/23 "2020-01-14T20:49:17Z")

</div>

The empty string is supposed to work as well (`balena help deploy`), but note the difference between _“empty string”_ and _“a space character between quotes”,_ i.e. `''` _vs._ `' '`. It’s coded here: [https://github.com/balena-io-modules/resin-multibuild/blob/v4.3.4/lib/registry-secrets.ts#L134-L136](https://github.com/balena-io-modules/resin-multibuild/blob/v4.3.4/lib/registry-secrets.ts#L134-L136)

Granted, the CLI could be a bit more flexible in that string matching. 🙂

---

<div class="post-metadata">

**Author:** ![gh\_laylapezeshkmher](https://avatars.discourse-cdn.com/v4/letter/g/8c91f0/32.png) [@gh\_laylapezeshkmher](https://forums.balena.io/u/gh_laylapezeshkmher)\
**Post date:** [January 14, 2020, 9:05pm UTC](https://forums.balena.io/t/deploy-a-pre-built-image-into-balena-using-local-mode/56058/24 "2020-01-14T21:05:38Z")

</div>

Hello, I just want to thank you for helping me out in deploying the pre built image to our local device. I have used an empty space and just for visibility I give it a space.

Adding the owners name as a prefix fixed the issue.

This is what I used as for the command:

Balena deploy owener’susername/appname name-of-the l-prebuilt-image —registry-secrets registry-secrets.yml

Thank you

Layla

---

<div class="post-metadata">

**Author:** ![jimsynz](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/jimsynz/32/4663_2.png) [@jimsynz](https://forums.balena.io/u/jimsynz)\
**Post date:** [January 14, 2020, 9:07pm UTC](https://forums.balena.io/t/deploy-a-pre-built-image-into-balena-using-local-mode/56058/25 "2020-01-14T21:07:46Z")

</div>

Hi Layla,

It’s our pleasure. I’m glad you got it working.

Thanks,  
James

---

<div class="post-metadata">

**Author:** ![gh\_laylapezeshkmher](https://avatars.discourse-cdn.com/v4/letter/g/8c91f0/32.png) [@gh\_laylapezeshkmher](https://forums.balena.io/u/gh_laylapezeshkmher)\
**Post date:** [January 14, 2020, 9:41pm UTC](https://forums.balena.io/t/deploy-a-pre-built-image-into-balena-using-local-mode/56058/27 "2020-01-14T21:41:15Z")

</div>

👍🏻

Thank you! Until my next unsolved issue!

Layla

---

<div class="post-metadata">

**Author:** ![gh\_laylapezeshkmher](https://avatars.discourse-cdn.com/v4/letter/g/8c91f0/32.png) [@gh\_laylapezeshkmher](https://forums.balena.io/u/gh_laylapezeshkmher)\
**Post date:** [January 17, 2020, 6:02pm UTC](https://forums.balena.io/t/deploy-a-pre-built-image-into-balena-using-local-mode/56058/29 "2020-01-17T18:02:27Z")

</div>

Hello and Good morning:  
I have a question regarding the session key under Preference, Access Tokens, Session token. I can’t recall how it was generated and why it is needed. I have noticed that it expires every 7 days. Will please let me know

thank you,

- Layla.

 ![Screen Shot 2020-01-17 at 9.58.26 AM.png](https://global.discourse-cdn.com/balena/original/2X/5/560449b5850c51e543f3aee56fdea032c94fc5ab.png)

---

<div class="post-metadata">

**Author:** ![tmigone](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/tmigone/32/2814_2.png) [@tmigone](https://forums.balena.io/u/tmigone)\
**Post date:** [January 17, 2020, 6:16pm UTC](https://forums.balena.io/t/deploy-a-pre-built-image-into-balena-using-local-mode/56058/30 "2020-01-17T18:16:18Z")

</div>

Hello! Good morning to you too.

Session tokens can be used for authentication in the balena API, CLI or the SDK’s. You can read more about it on our docs:  
[https://www.balena.io/docs/learn/manage/account/](https://www.balena.io/docs/learn/manage/account/)

Cheers!

---

<div class="post-metadata">

**Author:** ![tmigone](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/tmigone/32/2814_2.png) [@tmigone](https://forums.balena.io/u/tmigone)\
**Post date:** [January 17, 2020, 6:18pm UTC](https://forums.balena.io/t/deploy-a-pre-built-image-into-balena-using-local-mode/56058/31 "2020-01-17T18:18:11Z")

</div>

They are automatically generated and are only needed if you want to create a script or an automated process that requires authentication with a balena service.

---

<div class="post-metadata">

**Author:** ![gh\_laylapezeshkmher](https://avatars.discourse-cdn.com/v4/letter/g/8c91f0/32.png) [@gh\_laylapezeshkmher](https://forums.balena.io/u/gh_laylapezeshkmher)\
**Post date:** [January 17, 2020, 6:29pm UTC](https://forums.balena.io/t/deploy-a-pre-built-image-into-balena-using-local-mode/56058/33 "2020-01-17T18:29:54Z")

</div>

Thank you for the reply,  
yes that is the page which I have read. My question is that I can’t recall how this key was generated. Is it automatically generated or was there a way to create that. I would appreciate if you let me know.

thank you,

- Layla.

---

<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:** [January 17, 2020, 6:43pm UTC](https://forums.balena.io/t/deploy-a-pre-built-image-into-balena-using-local-mode/56058/34 "2020-01-17T18:43:27Z")

</div>

Hi @gh_laylapezeshkmher,  
A session token is generated whenever a user logs-in using their credentials, and that’s how our backend can identify each user and verify whether a request is authenticated or not.  
This is considered sensitive information, and should not be passed to others.  
In case that somehow a third person gets hold of your session token, then they will be to act on your behalf (for example generate more API keys).  
If there are such concerns, then you can use the “Log me out from other sessions” button in the “Account details” tab, which will invalidate the current session token and generate a new one.

Let me know in case you have further questions that you would like us to clarify.

Kind regards,  
Thodoris

---

<div class="post-metadata">

**Author:** ![gh\_laylapezeshkmher](https://avatars.discourse-cdn.com/v4/letter/g/8c91f0/32.png) [@gh\_laylapezeshkmher](https://forums.balena.io/u/gh_laylapezeshkmher)\
**Post date:** [January 17, 2020, 6:55pm UTC](https://forums.balena.io/t/deploy-a-pre-built-image-into-balena-using-local-mode/56058/36 "2020-01-17T18:55:40Z")

</div>

Thank you so much! I appreciate it
