| |
| |
| <!DOCTYPE html> |
| <html lang="en"> |
| <head> |
| <meta charset="utf-8"> |
| <meta http-equiv="X-UA-Compatible" content="IE=edge"> |
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> |
| |
| |
| |
| |
| <title>Everything You Need in a Docker Container — Apache Mynewt latest documentation</title> |
| |
| |
| |
| |
| <link rel="shortcut icon" href="../_static/mynewt-logo-only-newt32x32.png"/> |
| |
| |
| |
| |
| <link rel="stylesheet" href="../_static/css/theme.css" type="text/css" /> |
| |
| |
| <link rel="stylesheet" href="../_static/css/sphinx_theme.css" type="text/css" /> |
| |
| <link rel="stylesheet" href="../_static/css/bootstrap-3.0.3.min.css" type="text/css" /> |
| |
| <link rel="stylesheet" href="../_static/css/v2.css" type="text/css" /> |
| |
| <link rel="stylesheet" href="../_static/css/custom.css" type="text/css" /> |
| |
| <link rel="stylesheet" href="../_static/css/restructuredtext.css" type="text/css" /> |
| |
| |
| |
| |
| <link rel="stylesheet" href="../_static/css/overrides.css" type="text/css" /> |
| <link rel="index" title="Index" |
| href="../genindex.html"/> |
| <link rel="search" title="Search" href="../search.html"/> |
| <link rel="top" title="Apache Mynewt latest documentation" href="../index.html"/> |
| <link rel="up" title="Setup & Get Started" href="index.html"/> |
| <link rel="next" title="Creating Your First Mynewt Project" href="project_create.html"/> |
| <link rel="prev" title="Installing the Cross Tools for ARM" href="native_install/cross_tools.html"/> |
| |
| |
| <script src="../_static/js/modernizr.min.js"></script> |
| |
| |
| <script> |
| (function(i, s, o, g, r, a, m) { |
| i["GoogleAnalyticsObject"] = r; |
| (i[r] = |
| i[r] || |
| function() { |
| (i[r].q = i[r].q || []).push(arguments); |
| }), |
| (i[r].l = 1 * new Date()); |
| (a = s.createElement(o)), (m = s.getElementsByTagName(o)[0]); |
| a.async = 1; |
| a.src = g; |
| m.parentNode.insertBefore(a, m); |
| })(window, document, "script", "//www.google-analytics.com/analytics.js", "ga"); |
| |
| ga("create", "UA-72162311-1", "auto"); |
| ga("send", "pageview"); |
| </script> |
| |
| |
| </head> |
| |
| <body class="not-front page-documentation" role="document" > |
| <div id="wrapper"> |
| <div class="container"> |
| <div id="banner" class="row v2-main-banner"> |
| <a class="logo-cell" href="/"> |
| <img class="logo" src="../_static/img/logo.png"> |
| </a> |
| <div class="tagline-cell"> |
| <h4 class="tagline">An OS to build, deploy and securely manage billions of devices</h4> |
| </div> |
| <div class="news-cell"> |
| <div class="well"> |
| <h4>Latest News:</h4> <a href="/download">Apache Mynewt 1.11.0, Apache NimBLE 1.6.0 </a> released September 7, 2023) |
| </div> |
| </div> |
| </div> |
| </div> |
| |
| <header> |
| <nav id="navbar" class="navbar navbar-inverse" role="navigation"> |
| <div class="container"> |
| <!-- Collapsed navigation --> |
| <div class="navbar-header"> |
| <!-- Expander button --> |
| <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse"> |
| <span class="sr-only">Toggle navigation</span> |
| <span class="icon-bar"></span> |
| <span class="icon-bar"></span> |
| <span class="icon-bar"></span> |
| </button> |
| |
| </div> |
| |
| <!-- Expanded navigation --> |
| <div class="navbar-collapse collapse"> |
| <!-- Main navigation --> |
| <ul class="nav navbar-nav navbar-right"> |
| <li> |
| <a href="/"><i class="fa fa-home" style="font-size: larger;"></i></a> |
| </li> |
| <li class="important"> |
| <a href="/quick-start/">Quick Start</a> |
| </li> |
| <li> |
| <a href="/about/">About</a> |
| </li> |
| <li> |
| <a href="/talks/">Talks</a> |
| </li> |
| <li class="active"> |
| <a href="/documentation/">Documentation</a> |
| </li> |
| <li> |
| <a href="/download/">Download</a> |
| </li> |
| <li> |
| <a href="/community/">Community</a> |
| </li> |
| <li> |
| <a href="/events/">Events</a> |
| </li> |
| </ul> |
| |
| <!-- Search, Navigation and Repo links --> |
| <ul class="nav navbar-nav navbar-right"> |
| |
| </ul> |
| </div> |
| </div> |
| </nav> |
| </header> |
| <!-- STARTS MAIN CONTENT --> |
| <div id="main-content"> |
| |
| |
| |
| |
| |
| |
| <div id="breadcrumb"> |
| <div class="container"> |
| <a href="/documentation/">Docs</a> / |
| |
| <a href="index.html">Setup & Get Started</a> / |
| |
| Everything You Need in a Docker Container |
| |
| <div class="sourcelink"> |
| <a href="https://github.com/apache/mynewt-documentation/edit/master/docs/get_started/docker.rst" class="icon icon-github" |
| rel="nofollow"> Edit on GitHub</a> |
| </div> |
| </div> |
| </div> |
| <!-- STARTS CONTAINER --> |
| <div class="container"> |
| <!-- STARTS .content --> |
| <div id="content" class="row"> |
| |
| <!-- STARTS .container-sidebar --> |
| <div class="container-sidebar col-xs-12 col-sm-3"> |
| <div id="docSidebar" class="sticky-container"> |
| <div role="search" class="sphinx-search"> |
| <form id="rtd-search-form" class="wy-form" action="../search.html" method="get"> |
| <input type="text" name="q" placeholder="Search documentation" class="search-documentation" /> |
| <input type="hidden" name="check_keywords" value="yes" /> |
| <input type="hidden" name="area" value="default" /> |
| </form> |
| </div> |
| <!-- Note: only works when deployed --> |
| <select class="form-control" onchange="if (this.value) window.location.href=this.value"> |
| <option value="/latest" selected> |
| Version: latest |
| </option> |
| <option value="/v1_11_0" > |
| Version: 1.11.0 |
| </option> |
| <option value="/v1_10_0" > |
| Version: 1.10.0 |
| </option> |
| <option value="/v1_9_0" > |
| Version: 1.9.0 |
| </option> |
| <option value="/v1_8_0" > |
| Version: 1.8.0 |
| </option> |
| <option value="/v1_7_0" selected="selected" > |
| Version: 1.7.0 |
| </option> |
| <option value="/v1_6_0" > |
| Version: 1.6.0 |
| </option> |
| <option value="/v1_5_0" > |
| Version: 1.5.0 |
| </option> |
| <option value="/v1_4_0" > |
| Version: 1.4.0 |
| </option> |
| <option value="/v1_3_0/os/introduction" > |
| Version: 1.3.0 |
| </option> |
| <option value="/v1_2_0/os/introduction" > |
| Version: 1.2.0 |
| </option> |
| <option value="/v1_1_0/os/introduction" > |
| Version: 1.1.0 |
| </option> |
| <option value="/v1_0_0/os/introduction" > |
| Version: 1.0.0 |
| </option> |
| <option value="/v0_9_0/os/introduction" > |
| Version: 0.9.0 |
| </option> |
| </select> |
| <div class="region region-sidebar"> |
| <div class="docs-menu"> |
| |
| |
| |
| <ul class="current"> |
| <li class="toctree-l1"><a class="reference internal" href="../index.html">Introduction</a></li> |
| <li class="toctree-l1 current"><a class="reference internal" href="index.html">Setup & Get Started</a><ul class="current"> |
| <li class="toctree-l2"><a class="reference internal" href="native_install/index.html">Native Installation</a></li> |
| <li class="toctree-l2 current"><a class="current reference internal" href="#">Docker Container</a></li> |
| <li class="toctree-l2"><a class="reference internal" href="project_create.html">Create Your First Project</a></li> |
| <li class="toctree-l2"><a class="reference internal" href="serial_access.html">Serial Port Setup</a></li> |
| <li class="toctree-l2"><a class="reference internal" href="debug.html">Debugging Mynewt</a></li> |
| </ul> |
| </li> |
| <li class="toctree-l1"><a class="reference internal" href="../concepts.html">Concepts</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="../tutorials/tutorials.html">Tutorials</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="../external_links.html">Third-party Resources</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="../os/os_user_guide.html">OS User Guide</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="../network/index.html">BLE User Guide</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="../newt/index.html">Newt Tool Guide</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="../newtmgr/index.html">Newt Manager Guide</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="../mynewt_faq/index.html">Mynewt FAQ</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="../misc/index.html">Appendix</a></li> |
| </ul> |
| |
| |
| |
| </div> |
| </div> |
| </div> |
| <!-- ENDS STICKY CONTAINER --> |
| </div> |
| <!-- ENDS .container-sidebar --> |
| |
| <div class="col-xs-12 col-sm-9"> |
| |
| <div class="alert alert-warning"> |
| <p> |
| Version 1.7.0 is not the most recent version of the |
| Apache Mynewt documentation. Click <a href="/latest">here</a> to |
| read the latest version. |
| </p> |
| </div> |
| |
| |
| |
| <div class=""> |
| <div class="rst-content"> |
| <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article"> |
| <div itemprop="articleBody"> |
| |
| <div class="section" id="everything-you-need-in-a-docker-container"> |
| <h1>Everything You Need in a Docker Container<a class="headerlink" href="#everything-you-need-in-a-docker-container" title="Permalink to this headline">¶</a></h1> |
| <p>Docker provides a quick and easy way to get up and running with Mynewt. |
| The newt command line tool and the entire build toolchain is available |
| in a single docker container. The container is all that’s needed to run |
| your Mynewt based application in the simulator. Enabling USB2 with your |
| docker installation will allow you to load your application on a |
| supported device.</p> |
| <p>Docker is the only supported option if you are working on a Windows |
| machine. If you are using Mac OS X or Linux, you have the choice of |
| installing a Docker container of tools and toolchains or installing them |
| natively. This chapter describes how to set up the Docker image for all |
| three platforms.</p> |
| <div class="contents local topic" id="contents"> |
| <ul class="simple"> |
| <li><p><a class="reference internal" href="#install-docker" id="id1">Install Docker</a></p> |
| <ul> |
| <li><p><a class="reference internal" href="#mac-and-windows" id="id2">Mac and Windows</a></p></li> |
| <li><p><a class="reference internal" href="#linux" id="id3">Linux</a></p></li> |
| </ul> |
| </li> |
| <li><p><a class="reference internal" href="#pull-the-mynewt-container" id="id4">Pull the Mynewt Container</a></p></li> |
| <li><p><a class="reference internal" href="#use-a-newt-wrapper-script" id="id5">Use a <code class="docutils literal notranslate"><span class="pre">newt</span></code> wrapper script</a></p></li> |
| <li><p><a class="reference internal" href="#enable-usb2-support-for-mac-or-windows" id="id6">Enable USB2 Support for Mac or Windows</a></p> |
| <ul> |
| <li><p><a class="reference internal" href="#install-virtualbox-extension-pack" id="id7">Install VirtualBox extension pack</a></p></li> |
| <li><p><a class="reference internal" href="#enable-usb2-and-select-your-device" id="id8">Enable USB2 and select your device</a></p></li> |
| </ul> |
| </li> |
| </ul> |
| </div> |
| <div class="section" id="install-docker"> |
| <h2><a class="toc-backref" href="#id1">Install Docker</a><a class="headerlink" href="#install-docker" title="Permalink to this headline">¶</a></h2> |
| <p>Install docker for your platform. <a class="reference external" href="https://www.docker.com/products/docker-toolbox">Mac OS |
| X</a> / |
| <a class="reference external" href="https://www.docker.com/products/docker-toolbox">Windows</a> / |
| <a class="reference external" href="https://docs.docker.com/engine/installation/linux/">Linux</a></p> |
| <div class="section" id="mac-and-windows"> |
| <h3><a class="toc-backref" href="#id2">Mac and Windows</a><a class="headerlink" href="#mac-and-windows" title="Permalink to this headline">¶</a></h3> |
| <p>Mac and Windows require Docker Toolbox to interact with USB devices. |
| Docker for Mac and Docker for Windows do not support USB. Docker Toolbox |
| uses VirtualBox and allows you to map USB devices into docker containers |
| as described below.</p> |
| <p>Make sure to double click the Docker Quickstart Terminal application if |
| you’re on Mac or Windows.</p> |
| </div> |
| <div class="section" id="linux"> |
| <h3><a class="toc-backref" href="#id3">Linux</a><a class="headerlink" href="#linux" title="Permalink to this headline">¶</a></h3> |
| <p>The docker daemon listens on a Unix domain socket on Linux. That socket |
| is owned by root, which means by default you must be root to start a |
| container. Make sure to follow the optional step of adding yourself to |
| the docker group so you can start the newt container as yourself.</p> |
| </div> |
| </div> |
| <div class="section" id="pull-the-mynewt-container"> |
| <h2><a class="toc-backref" href="#id4">Pull the Mynewt Container</a><a class="headerlink" href="#pull-the-mynewt-container" title="Permalink to this headline">¶</a></h2> |
| <div class="highlight-console notranslate"><div class="highlight"><pre><span></span><span class="gp">$ </span>docker<span class="w"> </span>pull<span class="w"> </span>mynewt/newt:latest |
| </pre></div> |
| </div> |
| <p><strong>Note</strong> You can upgrade your container by repeating this command when updates are made available.</p> |
| </div> |
| <div class="section" id="use-a-newt-wrapper-script"> |
| <h2><a class="toc-backref" href="#id5">Use a <code class="docutils literal notranslate"><span class="pre">newt</span></code> wrapper script</a><a class="headerlink" href="#use-a-newt-wrapper-script" title="Permalink to this headline">¶</a></h2> |
| <p>Use the newt wrapper script to invoke newt. Create the following file, |
| name it <code class="docutils literal notranslate"><span class="pre">newt</span></code>, make it executable, and put it in your path. This will |
| allow you to run newt as if it was natively installed. You can now |
| follow the normal tutorials using the newt wrapper script.</p> |
| <div class="highlight-sh notranslate"><div class="highlight"><pre><span></span><span class="ch">#!/bin/bash</span> |
| |
| <span class="k">if</span><span class="w"> </span><span class="o">[</span><span class="w"> </span><span class="s2">"</span><span class="nv">$1</span><span class="s2">"</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s2">"debug"</span><span class="w"> </span><span class="o">]</span><span class="w"> </span><span class="o">||</span><span class="w"> </span><span class="o">[</span><span class="w"> </span><span class="s2">"</span><span class="nv">$1</span><span class="s2">"</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s2">"run"</span><span class="w"> </span><span class="o">]</span> |
| <span class="k">then</span> |
| <span class="w"> </span><span class="nv">ti</span><span class="o">=</span><span class="s2">"-ti"</span> |
| <span class="k">fi</span> |
| |
| docker<span class="w"> </span>run<span class="w"> </span>-e<span class="w"> </span><span class="nv">NEWT_USER</span><span class="o">=</span><span class="k">$(</span>id<span class="w"> </span>-u<span class="k">)</span><span class="w"> </span>-e<span class="w"> </span><span class="nv">NEWT_GROUP</span><span class="o">=</span><span class="k">$(</span>id<span class="w"> </span>-g<span class="k">)</span><span class="w"> </span>-e<span class="w"> </span><span class="nv">NEWT_HOST</span><span class="o">=</span><span class="k">$(</span>uname<span class="k">)</span><span class="w"> </span><span class="nv">$ti</span><span class="w"> </span>--rm<span class="w"> </span>--device<span class="o">=</span>/dev/bus/usb<span class="w"> </span>--privileged<span class="w"> </span>-v<span class="w"> </span><span class="k">$(</span><span class="nb">pwd</span><span class="k">)</span>:/workspace<span class="w"> </span>-w<span class="w"> </span>/workspace<span class="w"> </span>mynewt/newt:latest<span class="w"> </span>/newt<span class="w"> </span><span class="s2">"</span><span class="nv">$@</span><span class="s2">"</span> |
| </pre></div> |
| </div> |
| <p><strong>Note</strong> Remember to point to the correct subdirectory level when |
| invoking <code class="docutils literal notranslate"><span class="pre">newt</span></code>. For example, invoke it using <code class="docutils literal notranslate"><span class="pre">../newt</span></code> in the |
| example below.</p> |
| <div class="highlight-console notranslate"><div class="highlight"><pre><span></span><span class="gp">user@~/dockertest$ </span>ls |
| <span class="go">myproj newt</span> |
| <span class="gp">user@~/dockertest$ </span><span class="nb">cd</span><span class="w"> </span>myproj |
| <span class="gp">user@~/dockertest/myproj$ </span>../newt<span class="w"> </span>version |
| <span class="go">Apache Newt version: 1.1.0</span> |
| </pre></div> |
| </div> |
| </div> |
| <div class="section" id="enable-usb2-support-for-mac-or-windows"> |
| <h2><a class="toc-backref" href="#id6">Enable USB2 Support for Mac or Windows</a><a class="headerlink" href="#enable-usb2-support-for-mac-or-windows" title="Permalink to this headline">¶</a></h2> |
| <p>If you plan on loading your application on an actual device, do the |
| steps below.</p> |
| <div class="section" id="install-virtualbox-extension-pack"> |
| <h3><a class="toc-backref" href="#id7">Install VirtualBox extension pack</a><a class="headerlink" href="#install-virtualbox-extension-pack" title="Permalink to this headline">¶</a></h3> |
| <p>Docker uses a VirtualBox Linux VM to run containers. A free VirtualBox |
| extension pack is required to enable USB2 support. Download the |
| <a class="reference external" href="https://www.virtualbox.org/wiki/Downloads">VirtualBox Extension |
| Pack</a> version that matches |
| your VirtualBox installation and double click to install</p> |
| </div> |
| <div class="section" id="enable-usb2-and-select-your-device"> |
| <h3><a class="toc-backref" href="#id8">Enable USB2 and select your device</a><a class="headerlink" href="#enable-usb2-and-select-your-device" title="Permalink to this headline">¶</a></h3> |
| <ul class="simple"> |
| <li><p>The “default” VM created by docker-machine must first be stopped |
| before you can enable USB2. You have two options:</p> |
| <ul> |
| <li><p>Run the command <code class="docutils literal notranslate"><span class="pre">docker-machine</span> <span class="pre">stop</span> <span class="pre">default</span></code> in the terminal |
| window or</p></li> |
| <li><p>Use the VirtualBox UI. Right click on <code class="docutils literal notranslate"><span class="pre">default</span></code> -> Close -> |
| Power Off</p></li> |
| </ul> |
| </li> |
| <li><p>Enable USB2 using the VirtualBox UI. Select the “default” |
| VM->Settings->Ports->USB2 to enable USB2. Add your device to the USB |
| Device Filters to make the device visible in the docker container. |
| See the image below.</p></li> |
| <li><p>Restart the “default” VM. You have two options:</p> |
| <ul> |
| <li><p>Run <code class="docutils literal notranslate"><span class="pre">docker-machine</span> <span class="pre">start</span> <span class="pre">default</span></code> in the terminal window or</p></li> |
| <li><p>Use the VirtualBox UI. Make sure the “default” machine is |
| highlighted. Click the green “Start” button. Select “Headless Start”.</p></li> |
| </ul> |
| </li> |
| </ul> |
| <img alt="../_images/virtualbox_usb.jpg" src="../_images/virtualbox_usb.jpg" /> |
| <p><strong>Note</strong>: When working with actual hardware, remember that each board |
| has an ID. If you swap boards and do not refresh the USB Device Filter |
| on the VirtualBox UI, the ID might be stale and the Docker instance may |
| not be able to see the board correctly. For example, you may see an |
| error message like <code class="docutils literal notranslate"><span class="pre">Error:</span> <span class="pre">unable</span> <span class="pre">to</span> <span class="pre">find</span> <span class="pre">CMSIS-DAP</span> <span class="pre">device</span></code> when you |
| try to load or run an image on the board. In that case, you need to |
| click on the USB link in VirtualBox UI, remove the existing USB Device |
| Filter (e.g. “Atmel Corp. EDBG CMSIS-DAP[0101]”) by clicking on the |
| “Removes selected USB filter” button, and add a new filter by clicking |
| on the “Adds new USB filter” button.</p> |
| </div> |
| </div> |
| </div> |
| |
| |
| </div> |
| </div> |
| |
| <div class="rst-footer-buttons row" role="navigation" aria-label="footer navigation"> |
| |
| <a href="project_create.html" class="btn btn-neutral float-right" title="Creating Your First Mynewt Project" accesskey="n">Next: Creating Your First Mynewt Project <span class="fa fa-arrow-circle-right"></span></a> |
| |
| |
| <a href="native_install/cross_tools.html" class="btn btn-neutral" title="Installing the Cross Tools for ARM" accesskey="p"><span class="fa fa-arrow-circle-left"></span> Previous: Installing the Cross Tools for ARM</a> |
| |
| </div> |
| |
| </div> |
| </div> |
| </div> |
| <!-- ENDS CONTENT SECTION --> |
| </div> |
| <!-- ENDS .content --> |
| </div> |
| </div> |
| <footer> |
| <div class="container"> |
| <div class="row"> |
| <div class="col-xs-12"> |
| |
| <p class="copyright">Apache Mynewt is available under Apache License, version 2.0.</p> |
| |
| </div> |
| <div class="col-xs-12"> |
| <div class="logos"> |
| <img src="../_static/img/asf_logo_wide_small.png" alt="Apache" title="Apache"> |
| <small class="footnote"> |
| Apache Mynewt, Mynewt, Apache, the Apache feather logo, and the Apache Mynewt project logo are either |
| registered trademarks or trademarks of the Apache Software Foundation in the United States and other countries. |
| </small> |
| <a href=""> |
| <img src="../_static/img/add_to_slack.png" alt="Slack Icon" title="Join our Slack Community" /> |
| </a> |
| </div> |
| </div> |
| </div> |
| </div> |
| </footer> |
| </div> |
| <!-- ENDS #wrapper --> |
| |
| |
| |
| <script type="text/javascript"> |
| var DOCUMENTATION_OPTIONS = { |
| URL_ROOT:'../', |
| VERSION:'latest', |
| COLLAPSE_INDEX:false, |
| FILE_SUFFIX:'.html', |
| HAS_SOURCE: true, |
| SOURCELINK_SUFFIX: '.txt', |
| LINK_SUFFIX: '.html' |
| }; |
| </script> |
| <script type="text/javascript" src="../_static/jquery.js"></script> |
| <script type="text/javascript" src="../_static/underscore.js"></script> |
| <script type="text/javascript" src="../_static/doctools.js"></script> |
| <script type="text/javascript" src="../_static/js/bootstrap-3.0.3.min.js"></script> |
| <script type="text/javascript" src="../_static/js/affix.js"></script> |
| <script type="text/javascript" src="../_static/js/main.js"></script> |
| |
| |
| |
| </body> |
| </html> |