# Docker build fail

**URL:** <https://forums.balena.io/t/docker-build-fail/195495>\
**Category:** Product support\
**Tags:** raspberrypi3, raspberrypi4\
**Created:** [October 2, 2020, 5:26am UTC](https://forums.balena.io/t/docker-build-fail/195495 "2020-10-02T05:26:17Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![0xff](https://avatars.discourse-cdn.com/v4/letter/0/5fc32e/32.png) [@0xff](https://forums.balena.io/u/0xff)\
**Post date:** [October 2, 2020, 5:26am UTC](https://forums.balena.io/t/docker-build-fail/195495/1 "2020-10-02T05:26:18Z")

</div>

Actually Raspberry pi 4, but there doesn’t seem to be a tag for that.

I’m trying to build an image with both python and node. Here’s a simple `dockerfile.template`:

```
FROM balenalib/%%BALENA_MACHINE_NAME%%-ubuntu-python:3.7-build as build

RUN curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash -
RUN apt-get install nodejs

RUN echo "Hello"
COPY idle.sh idle.sh
CMD ["/bin/bash","-c",". idle.sh"]

```

If I skip lines 2 and 3, and execute them after logging into the container from the web terminal, they run fine and node 12 installs. However, the build fails when running it using `balena build`.

```
[Debug] Prepared tasks; building...
[Build] main Step 1/6 : FROM balenalib/raspberrypi4-64-ubuntu-python:3.7-build as build
[Build] main ---> 9267040b7ec9
[Build] main Step 2/6 : RUN curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash -
[Build] main ---> Using cache
[Build] main ---> b82bf1d13038
[Build] main Step 3/6 : RUN apt-get install nodejs
[Build] main ---> Running in 2e62ade8f100
[Build] main Reading package lists...
[Build] main Building dependency tree...
[Build] main Reading state information...
[Build] main E: Unable to locate package nodejs
[Build] Built 1 service in 0:01
[Error] Build failed
The command '/bin/sh -c apt-get install nodejs' returned a non-zero code: 100
Error: The command '/bin/sh -c apt-get install nodejs' returned a non-zero code: 100
    at Stream.<anonymous> (/usr/local/lib/node_modules/balena-cli/node_modules/resin-docker-build/build/builder.js:178:23)

```

What am I missing?

---

<div class="post-metadata">

**Author:** ![cmfcruz](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/cmfcruz/32/6878_2.png) [@cmfcruz](https://forums.balena.io/u/cmfcruz)\
**Post date:** [October 2, 2020, 10:05am UTC](https://forums.balena.io/t/docker-build-fail/195495/4 "2020-10-02T10:05:09Z")

</div>

Hi,

Please append the `-y` flag to the end of `RUN apt-get install nodejs`. The build is failing because the apt-get command prompts for a confirmation from the the user to proceed. The flag allows it to proceed without prompting the user. This is why it fails with a non-zero code.

Cheers,  
Carlo

---

<div class="post-metadata">

**Author:** ![0xff](https://avatars.discourse-cdn.com/v4/letter/0/5fc32e/32.png) [@0xff](https://forums.balena.io/u/0xff)\
**Post date:** [October 2, 2020, 3:45pm UTC](https://forums.balena.io/t/docker-build-fail/195495/6 "2020-10-02T15:45:20Z")

</div>

Thanks for the response. Same result:

```
[Build] main Step 3/6 : RUN apt-get install -y nodejs
[Build] main ---> Running in 9112a482f495
[Build] main Reading package lists...
[Build] main Building dependency tree...
[Build] main Reading state information...
[Build] main E: Unable to locate package nodejs
[Build] Built 1 service in 0:02
[Error] Build failed
The command '/bin/sh -c apt-get install -y nodejs' returned a non-zero code: 100
Error: The command '/bin/sh -c apt-get install -y nodejs' returned a non-zero code: 100
    at Stream.<anonymous> (/usr/local/lib/node_modules/balena-cli/node_modules/resin-docker-build/build/builder.js:178:23)
    at Stream.stream.write (/usr/local/lib/node_modules/balena-cli/node_modules/through/index.js:26:11)
    at Stream.ondata (internal/streams/legacy.js:19:31)

```

The error remains the same: “`Unable to locate package nodejs`”.

---

<div class="post-metadata">

**Author:** ![zvin](https://avatars.discourse-cdn.com/v4/letter/z/a5b964/32.png) [@zvin](https://forums.balena.io/u/zvin)\
**Post date:** [October 2, 2020, 4:31pm UTC](https://forums.balena.io/t/docker-build-fail/195495/7 "2020-10-02T16:31:34Z")

</div>

Hello,  
Can you please try editing the line `RUN curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash -` or any line before it, just to invalidate the cache. (Add a space after `curl` for example).

---

<div class="post-metadata">

**Author:** ![0xff](https://avatars.discourse-cdn.com/v4/letter/0/5fc32e/32.png) [@0xff](https://forums.balena.io/u/0xff)\
**Post date:** [October 5, 2020, 6:16pm UTC](https://forums.balena.io/t/docker-build-fail/195495/9 "2020-10-05T18:16:45Z")

</div>

Hi @zvin That may have done it - actually, I had done some experiments going backwards, that is starting from a node image and adding python, which worked and got my project going. Now when I went back to starting with a python image and adding node it seems to have worked w/o getting those errors.

---

<div class="post-metadata">

**Author:** ![dtischler](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/dtischler/32/2483_2.png) [@dtischler](https://forums.balena.io/u/dtischler)\
**Post date:** [October 5, 2020, 6:37pm UTC](https://forums.balena.io/t/docker-build-fail/195495/10 "2020-10-05T18:37:11Z")

</div>

Glad to hear that worked. 🙂

---

<div class="post-metadata">

**Author:** ![dtischler](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/dtischler/32/2483_2.png) [@dtischler](https://forums.balena.io/u/dtischler)\
**Post date:** [October 5, 2020, 6:38pm UTC](https://forums.balena.io/t/docker-build-fail/195495/11 "2020-10-05T18:38:04Z")

</div>

Also, thanks, I’ll add a tag for Raspberry Pi 4 for future use.
