| <!DOCTYPE html> |
| <html> |
| <head> |
| <meta charset="utf-8"> |
| <title>Apache Mesos - Containerizer Internals</title> |
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> |
| |
| <meta property="og:locale" content="en_US"/> |
| <meta property="og:type" content="website"/> |
| <meta property="og:title" content="Apache Mesos"/> |
| <meta property="og:site_name" content="Apache Mesos"/> |
| <meta property="og:url" content="http://mesos.apache.org/"/> |
| <meta property="og:image" content="http://mesos.apache.org/assets/img/mesos_logo_fb_preview.png"/> |
| <meta property="og:description" |
| content="Apache Mesos abstracts resources away from machines, |
| enabling fault-tolerant and elastic distributed systems |
| to easily be built and run effectively."/> |
| |
| <meta name="twitter:card" content="summary"/> |
| <meta name="twitter:site" content="@ApacheMesos"/> |
| <meta name="twitter:title" content="Apache Mesos"/> |
| <meta name="twitter:image" content="http://mesos.apache.org/assets/img/mesos_logo_fb_preview.png"/> |
| <meta name="twitter:description" |
| content="Apache Mesos abstracts resources away from machines, |
| enabling fault-tolerant and elastic distributed systems |
| to easily be built and run effectively."/> |
| |
| <link href="//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css" rel="stylesheet"> |
| <link rel="alternate" type="application/atom+xml" title="Apache Mesos Blog" href="/blog/feed.xml"> |
| <link href="../../assets/css/main.css" media="screen" rel="stylesheet" type="text/css" /> |
| |
| |
| |
| <!-- Google Analytics Magic --> |
| <script type="text/javascript"> |
| var _gaq = _gaq || []; |
| _gaq.push(['_setAccount', 'UA-20226872-1']); |
| _gaq.push(['_setDomainName', 'apache.org']); |
| _gaq.push(['_trackPageview']); |
| |
| (function() { |
| var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true; |
| ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js'; |
| var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s); |
| })(); |
| </script> |
| |
| </head> |
| <body> |
| <!-- magical breadcrumbs --> |
| <div class="topnav"> |
| <div class="container"> |
| <ul class="breadcrumb"> |
| <li> |
| <div class="dropdown"> |
| <a data-toggle="dropdown" href="#">Apache Software Foundation <span class="caret"></span></a> |
| <ul class="dropdown-menu" role="menu" aria-labelledby="dLabel"> |
| <li><a href="http://www.apache.org">Apache Homepage</a></li> |
| <li><a href="http://www.apache.org/licenses/">License</a></li> |
| <li><a href="http://www.apache.org/foundation/sponsorship.html">Sponsorship</a></li> |
| <li><a href="http://www.apache.org/foundation/thanks.html">Thanks</a></li> |
| <li><a href="http://www.apache.org/security/">Security</a></li> |
| </ul> |
| </div> |
| </li> |
| |
| <li><a href="http://mesos.apache.org">Apache Mesos</a></li> |
| |
| |
| <li><a href="/documentation |
| /">Documentation |
| </a></li> |
| |
| |
| </ul><!-- /.breadcrumb --> |
| </div><!-- /.container --> |
| </div><!-- /.topnav --> |
| |
| <!-- navbar excitement --> |
| <div class="navbar navbar-default navbar-static-top" role="navigation"> |
| <div class="container"> |
| <div class="navbar-header"> |
| <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#mesos-menu" aria-expanded="false"> |
| <span class="sr-only">Toggle navigation</span> |
| <span class="icon-bar"></span> |
| <span class="icon-bar"></span> |
| <span class="icon-bar"></span> |
| </button> |
| <a class="navbar-brand" href="/"><img src="/assets/img/mesos_logo.png" alt="Apache Mesos logo"/></a> |
| </div><!-- /.navbar-header --> |
| |
| <div class="navbar-collapse collapse" id="mesos-menu"> |
| <ul class="nav navbar-nav navbar-right"> |
| <li><a href="/gettingstarted/">Getting Started</a></li> |
| <li><a href="/blog/">Blog</a></li> |
| <li><a href="/documentation/latest/">Documentation</a></li> |
| <li><a href="/downloads/">Downloads</a></li> |
| <li><a href="/community/">Community</a></li> |
| </ul> |
| </div><!-- /#mesos-menu --> |
| </div><!-- /.container --> |
| </div><!-- /.navbar --> |
| |
| <div class="content"> |
| <div class="container"> |
| <div class="row-fluid"> |
| <div class="col-md-4"> |
| <h4>If you're new to Mesos</h4> |
| <p>See the <a href="/gettingstarted/">getting started</a> page for more |
| information about downloading, building, and deploying Mesos.</p> |
| |
| <h4>If you'd like to get involved or you're looking for support</h4> |
| <p>See our <a href="/community/">community</a> page for more details.</p> |
| </div> |
| <div class="col-md-8"> |
| <h1>Containerizer</h1> |
| |
| <p>Containerizers are Mesos components responsible for launching |
| containers. They own the containers launched for the tasks/executors, |
| and are responsible for their isolation, resource management, and |
| events (e.g., statistics).</p> |
| |
| <h1>Containerizer internals</h1> |
| |
| <h3>Containerizer creation and launch</h3> |
| |
| <ul> |
| <li>Agent creates a containerizer based on the flags (using agent flag |
| <code>--containerizers</code>). If multiple containerizers (e.g., docker, |
| mesos) are specified using the <code>--containerizers</code> flag, then the |
| composing containerizer will be used to create a containerizer.</li> |
| <li>If an executor is not specified in <code>TaskInfo</code>, Mesos agent will use |
| the default executor for the task (depending on the Containerizer |
| the agent is using, it could be <code>mesos-executor</code> or |
| <code>mesos-docker-executor</code>). TODO: Update this after MESOS-1718 is |
| completed. After this change, master will be responsible for |
| generating executor information.</li> |
| </ul> |
| |
| |
| <h3>Types of containerizers</h3> |
| |
| <p>Mesos currently supports the following containerizers:</p> |
| |
| <ul> |
| <li>Composing</li> |
| <li><a href="/documentation/latest/./docker-containerizer/">Docker</a></li> |
| <li><a href="/documentation/latest/./containerizer/">Mesos</a></li> |
| </ul> |
| |
| |
| <h4>Composing Containerizer</h4> |
| |
| <p>Composing containerizer will compose the specified containerizers |
| (using agent flag <code>--containerizers</code>) and act like a single |
| containerizer. This is an implementation of the <code>composite</code> design |
| pattern.</p> |
| |
| <h4>Docker Containerizer</h4> |
| |
| <p>Docker containerizer manages containers using the docker engine provided |
| in the docker package.</p> |
| |
| <h5>Container launch</h5> |
| |
| <ul> |
| <li>Docker containerizer will attempt to launch the task in docker only |
| if <code>ContainerInfo::type</code> is set to DOCKER.</li> |
| <li>Docker containerizer will first pull the image.</li> |
| <li>Calls pre-launch hook.</li> |
| <li>The executor will be launched in one of the two ways:</li> |
| </ul> |
| |
| |
| <p>A) Mesos agent runs in a docker container</p> |
| |
| <ul> |
| <li>This is indicated by the presence of agent flag |
| <code>--docker_mesos_image</code>. In this case, the value of flag |
| <code>--docker_mesos_image</code> is assumed to be the docker image used to |
| launch the Mesos agent.</li> |
| <li>If the task includes an executor (custom executor), then that executor is |
| launched in a docker container.</li> |
| <li>If the task does not include an executor i.e. it defines a command, the |
| default executor <code>mesos-docker-executor</code> is launched in a docker container to |
| execute the command via Docker CLI.</li> |
| </ul> |
| |
| |
| <p>B) Mesos agent does not run in a docker container</p> |
| |
| <ul> |
| <li>If the task includes an executor (custom executor), then that executor is |
| launched in a docker container.</li> |
| <li>If task does not include an executor i.e. it defines a command, a subprocess |
| is forked to execute the default executor <code>mesos-docker-executor</code>. |
| <code>mesos-docker-executor</code> then spawns a shell to execute the command via Docker |
| CLI.</li> |
| </ul> |
| |
| |
| <h4>Mesos Containerizer</h4> |
| |
| <p>Mesos containerizer is the native Mesos containerizer. Mesos |
| Containerizer will handle any executor/task that does not specify |
| <code>ContainerInfo::DockerInfo</code>.</p> |
| |
| <h5>Container launch</h5> |
| |
| <ul> |
| <li>Calls prepare on each isolator.</li> |
| <li>Forks the executor using Launcher (see <a href="#Launcher">Launcher</a>). The |
| forked child is blocked from executing until it is been isolated.</li> |
| <li>Isolate the executor. Call isolate with the pid for each isolator |
| (see <a href="#Isolators">Isolators</a>).</li> |
| <li>Fetch the executor.</li> |
| <li>Exec the executor. The forked child is signalled to continue. It |
| will first execute any preparation commands from isolators and then |
| exec the executor.</li> |
| </ul> |
| |
| |
| <p><a name="Launcher"></a></p> |
| |
| <h5>Launcher</h5> |
| |
| <p>Launcher is responsible for forking/destroying containers.</p> |
| |
| <ul> |
| <li>Forks a new process in the containerized context. The child will |
| exec the binary at the given path with the given argv, flags, and |
| environment.</li> |
| <li>The I/O of the child will be redirected according to the specified |
| I/O descriptors.</li> |
| </ul> |
| |
| |
| <h6>Linux launcher</h6> |
| |
| <ul> |
| <li>Creates a “freezer” cgroup for the container.</li> |
| <li>Creates posix “pipe” to enable communication between host (parent |
| process) and container process.</li> |
| <li>Spawn child process (container process) using <code>clone</code> system call.</li> |
| <li>Moves the new container process to the freezer hierarchy.</li> |
| <li>Signals the child process to continue (exec'ing) by writing a |
| character to the write end of the pipe in the parent process.</li> |
| </ul> |
| |
| |
| <h6>Posix launcher (TBD)</h6> |
| |
| <p><a name="Isolators"></a></p> |
| |
| <h5>Isolators</h5> |
| |
| <p>Isolators are responsible for creating an environment for the |
| containers where resources like cpu, network, storage and memory can |
| be isolated from other containers.</p> |
| |
| <h3>Containerizer states</h3> |
| |
| <h4>Docker</h4> |
| |
| <ul> |
| <li>FETCHING</li> |
| <li>PULLING</li> |
| <li>RUNNING</li> |
| <li>DESTROYING</li> |
| </ul> |
| |
| |
| <h4>Mesos</h4> |
| |
| <ul> |
| <li>PREPARING</li> |
| <li>ISOLATING</li> |
| <li>FETCHING</li> |
| <li>RUNNING</li> |
| <li>DESTROYING</li> |
| </ul> |
| |
| |
| </div> |
| </div> |
| |
| </div><!-- /.container --> |
| </div><!-- /.content --> |
| |
| <hr> |
| |
| |
| |
| <!-- footer --> |
| <div class="footer"> |
| <div class="container"> |
| <div class="col-md-4 social-blk"> |
| <span class="social"> |
| <a href="https://twitter.com/ApacheMesos" |
| class="twitter-follow-button" |
| data-show-count="false" data-size="large">Follow @ApacheMesos</a> |
| <script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+'://platform.twitter.com/widgets.js';fjs.parentNode.insertBefore(js,fjs);}}(document, 'script', 'twitter-wjs');</script> |
| <a href="https://twitter.com/intent/tweet?button_hashtag=mesos" |
| class="twitter-hashtag-button" |
| data-size="large" |
| data-related="ApacheMesos">Tweet #mesos</a> |
| <script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+'://platform.twitter.com/widgets.js';fjs.parentNode.insertBefore(js,fjs);}}(document, 'script', 'twitter-wjs');</script> |
| </span> |
| </div> |
| |
| <div class="col-md-8 trademark"> |
| <p>© 2012-2017 <a href="http://apache.org">The Apache Software Foundation</a>. |
| Apache Mesos, the Apache feather logo, and the Apache Mesos project logo are trademarks of The Apache Software Foundation. |
| <p> |
| </div> |
| </div><!-- /.container --> |
| </div><!-- /.footer --> |
| |
| <!-- JS --> |
| <script src="//code.jquery.com/jquery-1.11.0.min.js" type="text/javascript"></script> |
| <script src="//netdna.bootstrapcdn.com/bootstrap/3.1.1/js/bootstrap.min.js" type="text/javascript"></script> |
| </body> |
| </html> |