├── .github └── workflows │ └── flowzone.yml ├── .gitignore ├── .versionbot └── CHANGELOG.yml ├── CHANGELOG.md ├── Dockerfile.template ├── LICENSE ├── README.md ├── VERSION ├── conf └── systemd-watchdog.conf ├── docker-compose.yml ├── entry.sh ├── images └── balenaos-in-container.png └── repo.yml /.github/workflows/flowzone.yml: -------------------------------------------------------------------------------- 1 | name: Flowzone 2 | 3 | on: 4 | pull_request: 5 | types: [opened, synchronize, closed] 6 | branches: [main, master] 7 | # allow external contributions to use secrets within trusted code 8 | pull_request_target: 9 | types: [opened, synchronize, closed] 10 | branches: [main, master] 11 | 12 | jobs: 13 | flowzone: 14 | name: Flowzone 15 | uses: product-os/flowzone/.github/workflows/flowzone.yml@master 16 | # prevent duplicate workflow executions for pull_request and pull_request_target 17 | if: | 18 | ( 19 | github.event.pull_request.head.repo.full_name == github.repository && 20 | github.event_name == 'pull_request' 21 | ) || ( 22 | github.event.pull_request.head.repo.full_name != github.repository && 23 | github.event_name == 'pull_request_target' 24 | ) 25 | secrets: inherit 26 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.json 2 | .env 3 | -------------------------------------------------------------------------------- /.versionbot/CHANGELOG.yml: -------------------------------------------------------------------------------- 1 | - commits: 2 | - subject: Add note about incompatibility with OS 3.x+ 3 | hash: 6a9f1b83e52f41f1a07943e631b8ce22510813ad 4 | body: "" 5 | footer: 6 | Change-type: patch 7 | change-type: patch 8 | Signed-off-by: Christina Ying Wang 9 | signed-off-by: Christina Ying Wang 10 | author: Christina Ying Wang 11 | nested: [] 12 | version: 1.2.1 13 | title: "" 14 | date: 2025-03-31T19:10:01.480Z 15 | - commits: 16 | - subject: Pin OS release to latest known working version 17 | hash: ec7d1919626040ac24393a0a61ebac2205ddd1fa 18 | body: | 19 | 2.113.12 is also supported on generic-aarch64 20 | footer: 21 | Change-type: minor 22 | change-type: minor 23 | Signed-off-by: Kyle Harding 24 | signed-off-by: Kyle Harding 25 | author: Kyle Harding 26 | nested: [] 27 | version: 1.2.0 28 | title: "" 29 | date: 2024-05-31T15:25:11.845Z 30 | - commits: 31 | - subject: Switch from resinCI to Flowzone 32 | hash: 79695cb5254b8cd5542ef2cb21ecaaa1eeffdf71 33 | body: "" 34 | footer: 35 | Change-type: patch 36 | change-type: patch 37 | Signed-off-by: Kyle Harding 38 | signed-off-by: Kyle Harding 39 | author: Kyle Harding 40 | nested: [] 41 | version: 1.1.3 42 | title: "" 43 | date: 2023-08-22T16:18:03.840Z 44 | - commits: 45 | - subject: Adjust defaults for unified releases 46 | hash: 0f01b1be64c431259f98d506f22891024e81678e 47 | body: "" 48 | footer: 49 | Change-type: patch 50 | change-type: patch 51 | Signed-off-by: Alex Gonzalez 52 | signed-off-by: Alex Gonzalez 53 | author: Alex Gonzalez 54 | nested: [] 55 | version: 1.1.2 56 | title: "'Adjust defaults for unified releases'" 57 | date: 2022-05-02T12:34:47.281Z 58 | - commits: 59 | - subject: Inform users that cgroups v2 is not supported 60 | hash: 49d9045be27a948be0f6980ea5b628c5829679ec 61 | body: "" 62 | footer: 63 | Change-type: patch 64 | change-type: patch 65 | author: Taro Murao 66 | nested: [] 67 | version: 1.1.1 68 | title: "'Inform users that cgroups v2 is not supported'" 69 | date: 2022-02-25T12:06:15.098Z 70 | - commits: 71 | - subject: Add compose commands to clean old volumes and containers 72 | hash: cbadcff95f2c6fca5597fead71cc6a4ce9b0f524 73 | body: "" 74 | footer: 75 | Change-type: patch 76 | change-type: patch 77 | Signed-off-by: Kyle Harding 78 | signed-off-by: Kyle Harding 79 | author: Kyle Harding 80 | nested: [] 81 | - subject: Disable systemd-udev-trigger on boot 82 | hash: ebcb4286b7fcf748100d2ce32066d19321a537d3 83 | body: | 84 | This will avoid deplay crashes on some host systems. 85 | footer: 86 | Change-type: patch 87 | change-type: patch 88 | Signed-off-by: Kyle Harding 89 | signed-off-by: Kyle Harding 90 | author: Kyle Harding 91 | nested: [] 92 | - subject: Update balenaOS base image to v2.83.18 93 | hash: 12ed49d512cdf09c18ad76ab2f2f51097c20a8c8 94 | body: "" 95 | footer: 96 | Change-type: minor 97 | change-type: minor 98 | Signed-off-by: Kyle Harding 99 | signed-off-by: Kyle Harding 100 | author: Kyle Harding 101 | nested: [] 102 | version: 1.1.0 103 | title: "'Update balenaOS base image to v2.83.18'" 104 | date: 2022-02-14T16:16:47.940Z 105 | - commits: 106 | - subject: Use genericx86-64-ext device type 107 | hash: d33285a1cdd33b3d1e0c7bfccb050c0ad1fb9750 108 | body: "" 109 | footer: 110 | Change-type: patch 111 | change-type: patch 112 | Signed-off-by: Robert Günzler 113 | signed-off-by: Robert Günzler 114 | author: Robert Günzler 115 | nested: [] 116 | - subject: Remove scripts 117 | hash: fb1e81c1e11201084dfdf6544646c1159598bf50 118 | body: "" 119 | footer: 120 | Change-type: major 121 | change-type: major 122 | Signed-off-by: Robert Günzler 123 | signed-off-by: Robert Günzler 124 | author: Robert Günzler 125 | nested: [] 126 | - subject: Allocate a tty 127 | hash: 3e410f75d38a48cc2d4cb929bb54d07fefa3881c 128 | body: | 129 | With this systemd logs will be shown in the terminal 130 | footer: 131 | Change-type: patch 132 | change-type: patch 133 | Signed-off-by: Robert Günzler 134 | signed-off-by: Robert Günzler 135 | author: Robert Günzler 136 | nested: [] 137 | - subject: Add compose file 138 | hash: 1cc6f89fa461b3565083a9210bc2a40e066ba7e3 139 | body: | 140 | Replaces the start script and encapsulates all options required to run a 141 | balenaOS container on docker. 142 | footer: 143 | Change-type: minor 144 | change-type: minor 145 | Signed-off-by: Robert Günzler 146 | signed-off-by: Robert Günzler 147 | author: Robert Günzler 148 | nested: [] 149 | version: 1.0.0 150 | date: 2021-06-25T10:10:32.129Z 151 | - commits: 152 | - subject: Fix typo in Linux/macOS example in Linux/macOS example 153 | hash: 686aa50a8b2e4954a47abb0e3348936aa6178b43 154 | body: "" 155 | footer: 156 | Change-type: patch 157 | change-type: patch 158 | Signed-off-by: Rahul Thakoor 159 | signed-off-by: Rahul Thakoor 160 | author: Rahul Thakoor 161 | version: 0.5.3 162 | date: 2020-02-17T10:38:31.908Z 163 | - commits: 164 | - subject: Make the aufs2overlay script executable 165 | hash: 3450131efa45c2030aed1705e8b1681388bf1c28 166 | body: "" 167 | footer: 168 | Change-type: patch 169 | change-type: patch 170 | Signed-off-by: Cameron Diver 171 | signed-off-by: Cameron Diver 172 | author: Cameron Diver 173 | version: 0.5.2 174 | date: 2020-02-10T10:34:12.314Z 175 | - commits: 176 | - subject: "README: Updating example for available options" 177 | hash: f213179dd901b95c57773517fff855679f29d3dc 178 | body: "" 179 | footer: 180 | Change-type: patch 181 | change-type: patch 182 | Signed-off-by: Gareth Davies 183 | signed-off-by: Gareth Davies 184 | author: Gareth Davies 185 | version: 0.5.1 186 | date: 2020-02-05T22:34:01.375Z 187 | - commits: 188 | - subject: Add separate instructions for macOS/Linux and Windows 189 | hash: 4067ac9d0f412e0b3415e7def6e3ac3cddb01b0b 190 | body: "" 191 | footer: 192 | Change-type: minor 193 | change-type: minor 194 | Signed-off-by: Rahul Thakoor 195 | signed-off-by: Rahul Thakoor 196 | author: Rahul Thakoor 197 | version: 0.5.0 198 | date: 2020-02-03T05:50:12.140Z 199 | - commits: 200 | - subject: Update README.md with examples, and argument explanations 201 | hash: 9aceafdd781435b5306c62a2af948832282c3c77 202 | body: "" 203 | footer: 204 | Change-type: minor 205 | change-type: minor 206 | Signed-off-by: Thomas Manning 207 | signed-off-by: Thomas Manning 208 | author: Thomas Manning 209 | version: 0.4.0 210 | date: 2020-01-28T17:44:52.812Z 211 | - commits: 212 | - subject: Add powershell and aufs2overlay scripts 213 | hash: 19f0ea5c62f46704459c777cc38d3a146c28d7d4 214 | body: | 215 | - Include powershell script for running balenaos-in-container on Windows 216 | - migrate to overlay if image uses AUFS using aufs2overlay.sh script 217 | footer: 218 | Change-type: minor 219 | change-type: minor 220 | Signed-off-by: Rahul Thakoor 221 | signed-off-by: Rahul Thakoor 222 | author: Rahul Thakoor 223 | version: 0.3.0 224 | date: 2020-01-13T08:55:22.433Z 225 | - commits: 226 | - subject: "Fixes after config.json improvements in PR #19" 227 | hash: 00604decd384f9fc148f03d7da81824356ab8d52 228 | body: | 229 | Fixes #20 230 | footer: 231 | Change-type: patch 232 | change-type: patch 233 | Signed-off-by: Zubair Lutfullah Kakakhel 234 | signed-off-by: Zubair Lutfullah Kakakhel 235 | author: Zubair Lutfullah Kakakhel 236 | version: 0.2.1 237 | date: 2019-11-21T14:57:38.692Z 238 | - commits: 239 | - subject: Avoid repopulating the config.json when reusing the boot volume 240 | hash: 29c7da7b384187c12c48f7875e2332c2ef4bc8f2 241 | body: "" 242 | footer: 243 | Change-type: minor 244 | change-type: minor 245 | author: Pagan Gazzard 246 | version: 0.2.0 247 | date: 2019-11-18T18:37:47.411Z 248 | - commits: 249 | - subject: Move to balena overall and add name prefix 250 | hash: 391212a6f3736d74d33a5745d4c5c9ad0738f1ee 251 | body: | 252 | Also trying to fix up versioning 253 | footer: 254 | Change-type: minor 255 | change-type: minor 256 | Signed-off-by: Gergely Imreh 257 | signed-off-by: Gergely Imreh 258 | author: Gergely Imreh 259 | version: 0.1.0 260 | date: 2019-09-30T12:58:04.069Z 261 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | 3 | All notable changes to this project will be documented in this file 4 | automatically by Versionist. DO NOT EDIT THIS FILE MANUALLY! 5 | This project adheres to [Semantic Versioning](http://semver.org/). 6 | 7 | # v1.2.1 8 | ## (2025-03-31) 9 | 10 | * Add note about incompatibility with OS 3.x+ [Christina Ying Wang] 11 | 12 | # v1.2.0 13 | ## (2024-05-31) 14 | 15 | * Pin OS release to latest known working version [Kyle Harding] 16 | 17 | # v1.1.3 18 | ## (2023-08-22) 19 | 20 | * Switch from resinCI to Flowzone [Kyle Harding] 21 | 22 | # v1.1.2 23 | ## (2022-05-02) 24 | 25 | * Adjust defaults for unified releases [Alex Gonzalez] 26 | 27 | # v1.1.1 28 | ## (2022-02-25) 29 | 30 | * Inform users that cgroups v2 is not supported [Taro Murao] 31 | 32 | # v1.1.0 33 | ## (2022-02-14) 34 | 35 | * Add compose commands to clean old volumes and containers [Kyle Harding] 36 | * Disable systemd-udev-trigger on boot [Kyle Harding] 37 | * Update balenaOS base image to v2.83.18 [Kyle Harding] 38 | 39 | # v1.0.0 40 | ## (2021-06-25) 41 | 42 | * Use genericx86-64-ext device type [Robert Günzler] 43 | * Remove scripts [Robert Günzler] 44 | * Allocate a tty [Robert Günzler] 45 | * Add compose file [Robert Günzler] 46 | 47 | # v0.5.3 48 | ## (2020-02-17) 49 | 50 | * Fix typo in Linux/macOS example in Linux/macOS example [Rahul Thakoor] 51 | 52 | # v0.5.2 53 | ## (2020-02-10) 54 | 55 | * Make the aufs2overlay script executable [Cameron Diver] 56 | 57 | # v0.5.1 58 | ## (2020-02-05) 59 | 60 | * README: Updating example for available options [Gareth Davies] 61 | 62 | # v0.5.0 63 | ## (2020-02-03) 64 | 65 | * Add separate instructions for macOS/Linux and Windows [Rahul Thakoor] 66 | 67 | # v0.4.0 68 | ## (2020-01-28) 69 | 70 | * Update README.md with examples, and argument explanations [Thomas Manning] 71 | 72 | # v0.3.0 73 | ## (2020-01-13) 74 | 75 | * Add powershell and aufs2overlay scripts [Rahul Thakoor] 76 | 77 | # v0.2.1 78 | ## (2019-11-21) 79 | 80 | * Fixes after config.json improvements in PR #19 [Zubair Lutfullah Kakakhel] 81 | 82 | # v0.2.0 83 | ## (2019-11-18) 84 | 85 | * Avoid repopulating the config.json when reusing the boot volume [Pagan Gazzard] 86 | 87 | # v0.1.0 88 | ## (2019-09-30) 89 | 90 | * Move to balena overall and add name prefix [Gergely Imreh] 91 | -------------------------------------------------------------------------------- /Dockerfile.template: -------------------------------------------------------------------------------- 1 | # syntax=docker/dockerfile:1.2 2 | 3 | ARG OS_VERSION 4 | ARG DEVICE_TYPE=%%BALENA_MACHINE_NAME%% 5 | 6 | # hadolint ignore=DL3007 7 | FROM bh.cr/balena_os/${DEVICE_TYPE}/${OS_VERSION}:latest 8 | 9 | COPY ./entry.sh /entry.sh 10 | COPY ./conf/systemd-watchdog.conf /etc/systemd/system.conf.d/watchdog.conf 11 | 12 | ENV container=docker 13 | 14 | VOLUME /mnt/boot \ 15 | /mnt/state \ 16 | /mnt/data 17 | 18 | CMD [ "/entry.sh" ] 19 | 20 | # avoid display crash on some host systems 21 | RUN rm /lib/systemd/system/sysinit.target.wants/systemd-udev-trigger.service 22 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | 2 | 3 | Apache License 4 | Version 2.0, January 2004 5 | http://www.apache.org/licenses/ 6 | 7 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 8 | 9 | 1. Definitions. 10 | 11 | "License" shall mean the terms and conditions for use, reproduction, 12 | and distribution as defined by Sections 1 through 9 of this document. 13 | 14 | "Licensor" shall mean the copyright owner or entity authorized by 15 | the copyright owner that is granting the License. 16 | 17 | "Legal Entity" shall mean the union of the acting entity and all 18 | other entities that control, are controlled by, or are under common 19 | control with that entity. For the purposes of this definition, 20 | "control" means (i) the power, direct or indirect, to cause the 21 | direction or management of such entity, whether by contract or 22 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 23 | outstanding shares, or (iii) beneficial ownership of such entity. 24 | 25 | "You" (or "Your") shall mean an individual or Legal Entity 26 | exercising permissions granted by this License. 27 | 28 | "Source" form shall mean the preferred form for making modifications, 29 | including but not limited to software source code, documentation 30 | source, and configuration files. 31 | 32 | "Object" form shall mean any form resulting from mechanical 33 | transformation or translation of a Source form, including but 34 | not limited to compiled object code, generated documentation, 35 | and conversions to other media types. 36 | 37 | "Work" shall mean the work of authorship, whether in Source or 38 | Object form, made available under the License, as indicated by a 39 | copyright notice that is included in or attached to the work 40 | (an example is provided in the Appendix below). 41 | 42 | "Derivative Works" shall mean any work, whether in Source or Object 43 | form, that is based on (or derived from) the Work and for which the 44 | editorial revisions, annotations, elaborations, or other modifications 45 | represent, as a whole, an original work of authorship. For the purposes 46 | of this License, Derivative Works shall not include works that remain 47 | separable from, or merely link (or bind by name) to the interfaces of, 48 | the Work and Derivative Works thereof. 49 | 50 | "Contribution" shall mean any work of authorship, including 51 | the original version of the Work and any modifications or additions 52 | to that Work or Derivative Works thereof, that is intentionally 53 | submitted to Licensor for inclusion in the Work by the copyright owner 54 | or by an individual or Legal Entity authorized to submit on behalf of 55 | the copyright owner. For the purposes of this definition, "submitted" 56 | means any form of electronic, verbal, or written communication sent 57 | to the Licensor or its representatives, including but not limited to 58 | communication on electronic mailing lists, source code control systems, 59 | and issue tracking systems that are managed by, or on behalf of, the 60 | Licensor for the purpose of discussing and improving the Work, but 61 | excluding communication that is conspicuously marked or otherwise 62 | designated in writing by the copyright owner as "Not a Contribution." 63 | 64 | "Contributor" shall mean Licensor and any individual or Legal Entity 65 | on behalf of whom a Contribution has been received by Licensor and 66 | subsequently incorporated within the Work. 67 | 68 | 2. Grant of Copyright License. Subject to the terms and conditions of 69 | this License, each Contributor hereby grants to You a perpetual, 70 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 71 | copyright license to reproduce, prepare Derivative Works of, 72 | publicly display, publicly perform, sublicense, and distribute the 73 | Work and such Derivative Works in Source or Object form. 74 | 75 | 3. Grant of Patent License. Subject to the terms and conditions of 76 | this License, each Contributor hereby grants to You a perpetual, 77 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 78 | (except as stated in this section) patent license to make, have made, 79 | use, offer to sell, sell, import, and otherwise transfer the Work, 80 | where such license applies only to those patent claims licensable 81 | by such Contributor that are necessarily infringed by their 82 | Contribution(s) alone or by combination of their Contribution(s) 83 | with the Work to which such Contribution(s) was submitted. If You 84 | institute patent litigation against any entity (including a 85 | cross-claim or counterclaim in a lawsuit) alleging that the Work 86 | or a Contribution incorporated within the Work constitutes direct 87 | or contributory patent infringement, then any patent licenses 88 | granted to You under this License for that Work shall terminate 89 | as of the date such litigation is filed. 90 | 91 | 4. Redistribution. You may reproduce and distribute copies of the 92 | Work or Derivative Works thereof in any medium, with or without 93 | modifications, and in Source or Object form, provided that You 94 | meet the following conditions: 95 | 96 | (a) You must give any other recipients of the Work or 97 | Derivative Works a copy of this License; and 98 | 99 | (b) You must cause any modified files to carry prominent notices 100 | stating that You changed the files; and 101 | 102 | (c) You must retain, in the Source form of any Derivative Works 103 | that You distribute, all copyright, patent, trademark, and 104 | attribution notices from the Source form of the Work, 105 | excluding those notices that do not pertain to any part of 106 | the Derivative Works; and 107 | 108 | (d) If the Work includes a "NOTICE" text file as part of its 109 | distribution, then any Derivative Works that You distribute must 110 | include a readable copy of the attribution notices contained 111 | within such NOTICE file, excluding those notices that do not 112 | pertain to any part of the Derivative Works, in at least one 113 | of the following places: within a NOTICE text file distributed 114 | as part of the Derivative Works; within the Source form or 115 | documentation, if provided along with the Derivative Works; or, 116 | within a display generated by the Derivative Works, if and 117 | wherever such third-party notices normally appear. The contents 118 | of the NOTICE file are for informational purposes only and 119 | do not modify the License. You may add Your own attribution 120 | notices within Derivative Works that You distribute, alongside 121 | or as an addendum to the NOTICE text from the Work, provided 122 | that such additional attribution notices cannot be construed 123 | as modifying the License. 124 | 125 | You may add Your own copyright statement to Your modifications and 126 | may provide additional or different license terms and conditions 127 | for use, reproduction, or distribution of Your modifications, or 128 | for any such Derivative Works as a whole, provided Your use, 129 | reproduction, and distribution of the Work otherwise complies with 130 | the conditions stated in this License. 131 | 132 | 5. Submission of Contributions. Unless You explicitly state otherwise, 133 | any Contribution intentionally submitted for inclusion in the Work 134 | by You to the Licensor shall be under the terms and conditions of 135 | this License, without any additional terms or conditions. 136 | Notwithstanding the above, nothing herein shall supersede or modify 137 | the terms of any separate license agreement you may have executed 138 | with Licensor regarding such Contributions. 139 | 140 | 6. Trademarks. This License does not grant permission to use the trade 141 | names, trademarks, service marks, or product names of the Licensor, 142 | except as required for reasonable and customary use in describing the 143 | origin of the Work and reproducing the content of the NOTICE file. 144 | 145 | 7. Disclaimer of Warranty. Unless required by applicable law or 146 | agreed to in writing, Licensor provides the Work (and each 147 | Contributor provides its Contributions) on an "AS IS" BASIS, 148 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 149 | implied, including, without limitation, any warranties or conditions 150 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 151 | PARTICULAR PURPOSE. You are solely responsible for determining the 152 | appropriateness of using or redistributing the Work and assume any 153 | risks associated with Your exercise of permissions under this License. 154 | 155 | 8. Limitation of Liability. In no event and under no legal theory, 156 | whether in tort (including negligence), contract, or otherwise, 157 | unless required by applicable law (such as deliberate and grossly 158 | negligent acts) or agreed to in writing, shall any Contributor be 159 | liable to You for damages, including any direct, indirect, special, 160 | incidental, or consequential damages of any character arising as a 161 | result of this License or out of the use or inability to use the 162 | Work (including but not limited to damages for loss of goodwill, 163 | work stoppage, computer failure or malfunction, or any and all 164 | other commercial damages or losses), even if such Contributor 165 | has been advised of the possibility of such damages. 166 | 167 | 9. Accepting Warranty or Additional Liability. While redistributing 168 | the Work or Derivative Works thereof, You may choose to offer, 169 | and charge a fee for, acceptance of support, warranty, indemnity, 170 | or other liability obligations and/or rights consistent with this 171 | License. However, in accepting such obligations, You may act only 172 | on Your own behalf and on Your sole responsibility, not on behalf 173 | of any other Contributor, and only if You agree to indemnify, 174 | defend, and hold each Contributor harmless for any liability 175 | incurred by, or claims asserted against, such Contributor by reason 176 | of your accepting any such warranty or additional liability. 177 | 178 | END OF TERMS AND CONDITIONS 179 | 180 | APPENDIX: How to apply the Apache License to your work. 181 | 182 | To apply the Apache License to your work, attach the following 183 | boilerplate notice, with the fields enclosed by brackets "[]" 184 | replaced with your own identifying information. (Don`t include 185 | the brackets!) The text should be enclosed in the appropriate 186 | comment syntax for the file format. We also recommend that a 187 | file or class name and description of purpose be included on the 188 | same "printed page" as the copyright notice for easier 189 | identification within third-party archives. 190 | 191 | Copyright [yyyy] [name of copyright owner] 192 | 193 | Licensed under the Apache License, Version 2.0 (the "License"); 194 | you may not use this file except in compliance with the License. 195 | You may obtain a copy of the License at 196 | 197 | http://www.apache.org/licenses/LICENSE-2.0 198 | 199 | Unless required by applicable law or agreed to in writing, software 200 | distributed under the License is distributed on an "AS IS" BASIS, 201 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 202 | See the License for the specific language governing permissions and 203 | limitations under the License. 204 | 205 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ![balenaOS in container](/images/balenaos-in-container.png) 2 | 3 | > NOTE: This tool does not currently work with OS 3.x+. For a better virtualization option, please use [QEMU](https://docs.balena.io/learn/getting-started/qemux86-64/nodejs/). 4 | 5 | # balenaOS in a docker container 6 | 7 | This is a tool which enables running balenaOS docker images as a docker container. 8 | 9 | ## Prerequisites 10 | 11 | Before running this tool make sure: 12 | 13 | 1. Docker daemon is running 14 | 2. Current user has privileges to run docker commands. 15 | 3. Depending on what balenaOS image you are trying to boot, you might need aufs or overlayfs on your host. 16 | 4. The balenaOS image is compatible with the architecture where you are running the script. e.g. If you are running this script on your laptop (x86_64), you can run balenaOS images built for the NUC which are also x86_64. [***](#running-other-architectures) 17 | 5. `balenaos-in-container` does not support [`cgroups v2`](https://www.kernel.org/doc/html/latest/admin-guide/cgroup-v2.html) yet. Check the version of `cgroups` of your machine. [Guides for Linux users](https://unix.stackexchange.com/questions/619681/how-can-i-find-out-what-version-of-cgroups-i-have), and [Docker Desktop on Mac users](https://docs.docker.com/desktop/mac/release-notes/#bug-fixes-and-minor-changes-1). Downgrade your `cgroups` to v1 if you want to use `balenaos-in-container`. 18 | 19 | ## How to use 20 | 21 | ```bash 22 | docker-compose up --build 23 | ``` 24 | 25 | This assumes you have a `config.json` in the project directory. It can be downloaded from your balenaCloud dashboard. Once you have added an application click "Add a new device", click to expand the "Advanced" section and check "Download configuration file only" now click "Download configuration file". 26 | 27 | You can find the latest balenaOS images on [dockerhub](https://hub.docker.com/r/resin/resinos/tags). 28 | 29 | If you need to clear volumes and start with a clean state, use the following compose commands: 30 | 31 | ```bash 32 | # bring down all services and remove volumes 33 | docker-compose down --volumes --remove-orphans 34 | 35 | # build and bring up services again with new volumes 36 | docker-compose up -d --build 37 | ``` 38 | 39 | ## Running other architectures 40 | 41 | It's possible to run a container images that target other platforms than your host system by registering QEMU's user-mode emulation. 42 | Check out https://github.com/dbhi/qus/#setup for how to set that up. 43 | 44 | ## Development 45 | 46 | Want to contribute? Great! Throw pull requests at us. 47 | -------------------------------------------------------------------------------- /VERSION: -------------------------------------------------------------------------------- 1 | 1.2.1 -------------------------------------------------------------------------------- /conf/systemd-watchdog.conf: -------------------------------------------------------------------------------- 1 | [Manager] 2 | RuntimeWatchdogSec=0 3 | -------------------------------------------------------------------------------- /docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: '2.2' 2 | 3 | services: 4 | os: 5 | build: 6 | context: . 7 | dockerfile: Dockerfile.template 8 | args: 9 | # currently only versions below v2.114.0 are working 10 | # see https://github.com/balena-os/balenaos-in-container/issues/60 11 | OS_VERSION: ${OS_VERSION:-2.113.12} 12 | DEVICE_TYPE: ${DEVICE_TYPE:-generic-amd64} 13 | privileged: true 14 | stop_signal: SIGRTMIN+3 15 | stop_grace_period: 30s 16 | volumes: 17 | - /lib/modules:/lib/modules:ro 18 | - ${CONFIG_JSON:-./config.json}:/var/local/config.json:ro 19 | - boot:/mnt/boot 20 | - data:/mnt/data 21 | - state:/mnt/state 22 | tmpfs: 23 | - /run 24 | - /run/lock 25 | - /tmp 26 | - /var/lib/journal 27 | - /sys/fs/cgroup/systemd 28 | # this is required for the dns option to have any effect 29 | # see https://github.com/docker/compose/issues/2847#issuecomment-658999887 30 | network_mode: bridge 31 | dns: 32 | - 127.0.0.2 33 | tty: true 34 | 35 | volumes: 36 | boot: 37 | data: 38 | state: 39 | -------------------------------------------------------------------------------- /entry.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # switch storage driver to overlay2 4 | units="/lib/systemd/system/balena.service" 5 | if [ -f /etc/systemd/system/balena.service.d/balena.conf ]; then 6 | units="${units} /etc/systemd/system/balena.service.d/balena.conf" 7 | fi 8 | for unit in $units; do 9 | sed -i "s/-s aufs/-s overlay2/g" "${unit}" 10 | done 11 | 12 | # copy device-type.json into the place the supervisor looks for it 13 | [ ! -f /mnt/boot/device-type.json ] && cp /resin-boot/device-type.json /mnt/boot/ 14 | # copy config.json into boot partition 15 | [ ! -f /mnt/boot/config.json ] && cp /var/local/config.json /mnt/boot/ 16 | 17 | exec /sbin/init 18 | -------------------------------------------------------------------------------- /images/balenaos-in-container.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/balena-os/balenaos-in-container/421a337531448bffee8361db0b5f746c11a5e71f/images/balenaos-in-container.png -------------------------------------------------------------------------------- /repo.yml: -------------------------------------------------------------------------------- 1 | type: 'generic' 2 | --------------------------------------------------------------------------------