Files
clear-linux-documentation/tutorials/docker.html
2024-11-04 18:48:51 +00:00

336 lines
20 KiB
HTML
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<!DOCTYPE html>
<html lang="en" data-content_root="../">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Docker* &#8212; Documentation for Clear Linux* project</title>
<link rel="stylesheet" type="text/css" href="../_static/pygments.css?v=fa44fd50" />
<link rel="stylesheet" type="text/css" href="../_static/bizstyle.css?v=5283bb3d" />
<link rel="stylesheet" type="text/css" href="../_static/copybutton.css?v=76b2166b" />
<script src="../_static/documentation_options.js?v=5929fcd5"></script>
<script src="../_static/doctools.js?v=9bcbadda"></script>
<script src="../_static/sphinx_highlight.js?v=dc90522c"></script>
<script src="../_static/clipboard.min.js?v=a7894cd8"></script>
<script src="../_static/copybutton.js?v=a56c686a"></script>
<script src="../_static/bizstyle.js"></script>
<link rel="canonical" href="https://clearlinux.github.io/clear-linux-documentation/tutorials/docker.html" />
<link rel="icon" href="../_static/favicon.ico"/>
<link rel="author" title="About these documents" href="../about.html" />
<link rel="index" title="Index" href="../genindex.html" />
<link rel="search" title="Search" href="../search.html" />
<link rel="next" title="Flatpak*" href="flatpak.html" />
<link rel="prev" title="Broadcom* Drivers" href="broadcom.html" />
<meta name="viewport" content="width=device-width,initial-scale=1.0" />
<!--[if lt IE 9]>
<script src="_static/css3-mediaqueries.js"></script>
<![endif]-->
</head><body>
<div class="related" role="navigation" aria-label="Related">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="../genindex.html" title="General Index"
accesskey="I">index</a></li>
<li class="right" >
<a href="flatpak.html" title="Flatpak*"
accesskey="N">next</a> |</li>
<li class="right" >
<a href="broadcom.html" title="Broadcom* Drivers"
accesskey="P">previous</a> |</li>
<li class="nav-item nav-item-0"><a href="../index.html">Documentation for Clear Linux* project</a> &#187;</li>
<li class="nav-item nav-item-1"><a href="index.html" accesskey="U">Tutorials</a> &#187;</li>
<li class="nav-item nav-item-this"><a href="">Docker*</a></li>
</ul>
</div>
<div class="document">
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body" role="main">
<section id="docker">
<span id="id1"></span><h1>Docker*<a class="headerlink" href="#docker" title="Link to this heading"></a></h1>
<p>Clear Linux* OS supports multiple containerization platforms, including a Docker
solution. Clear Linux OS has many unique features including a minimal default
installation, which makes it compelling to use as a host for container
workloads, management, and orchestration.</p>
<p>This tutorial covers:</p>
<nav class="contents local" id="contents">
<ul class="simple">
<li><p><a class="reference internal" href="#prerequisites" id="id3">Prerequisites</a></p></li>
<li><p><a class="reference internal" href="#install-the-containers-basic-bundle" id="id4">Install the containers-basic bundle</a></p></li>
<li><p><a class="reference internal" href="#integration-with-kata-containers-optional" id="id5">Integration with Kata Containers* (optional)</a></p></li>
<li><p><a class="reference internal" href="#additional-docker-configuration" id="id6">Additional Docker configuration</a></p></li>
<li><p><a class="reference internal" href="#pulling-and-running-an-image-from-docker-hub" id="id7">Pulling and running an image from Docker Hub*</a></p></li>
<li><p><a class="reference internal" href="#creating-a-docker-swarm-cluster" id="id8">Creating a Docker swarm cluster</a></p></li>
<li><p><a class="reference internal" href="#related-topics" id="id9">Related topics</a></p></li>
</ul>
</nav>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>This tutorial focuses on the installation of the Docker ecosystem.
If you want to use Clear Linux OS as a Docker container image, refer to the
official Clear Linux OS container image
<a class="reference external" href="https://hub.docker.com/_/clearlinux/">published on Docker* Hub</a>
and our guide to <a class="reference internal" href="../guides/maintenance/container-image-new.html#container-image-new"><span class="std std-ref">Build a new Clear Linux OS-based container image</span></a>.</p>
</div>
<section id="prerequisites">
<h2><a class="toc-backref" href="#id3" role="doc-backlink">Prerequisites</a><a class="headerlink" href="#prerequisites" title="Link to this heading"></a></h2>
<p>This tutorial assumes you have installed Clear Linux OS on your host system.
For detailed instructions on installing Clear Linux OS on a bare metal system, follow
the <a class="reference internal" href="../get-started/bare-metal-install-server.html#bare-metal-install-server"><span class="std std-ref">bare metal installation instructions</span></a>.</p>
<p>Before you install any new packages, update Clear Linux OS with the following command:</p>
<div class="highlight-bash notranslate"><div class="highlight"><pre><span></span>sudo<span class="w"> </span>swupd<span class="w"> </span>update
</pre></div>
</div>
<p>Additionally, you should have:</p>
<ul class="simple">
<li><p>A basic understanding of Linux* and Docker.</p></li>
<li><p>Clear Linux OS environment that has transparent network access to the Internet.
If you are behind a HTTP proxy server, in a corporate setting for example,
please refer to the <a class="reference external" href="https://docs.docker.com/config/daemon/systemd/#httphttps-proxy">Docker proxy instructions</a> .</p></li>
</ul>
</section>
<section id="install-the-containers-basic-bundle">
<h2><a class="toc-backref" href="#id4" role="doc-backlink">Install the containers-basic bundle</a><a class="headerlink" href="#install-the-containers-basic-bundle" title="Link to this heading"></a></h2>
<p>Software in Clear Linux OS is offered in the form of <a class="reference internal" href="../reference/bundles/bundles.html#bundles"><span class="std std-ref">Available bundles</span></a> to provide a
complete function. The <em>containers-basic</em> provides all the required software
packages to run Docker images as containers.</p>
<ol class="arabic">
<li><p>First, install the <em>containers-basic</em> bundle by running this
<strong class="command">swupd</strong> command:</p>
<div class="highlight-bash notranslate"><div class="highlight"><pre><span></span>sudo<span class="w"> </span>swupd<span class="w"> </span>bundle-add<span class="w"> </span>containers-basic
</pre></div>
</div>
</li>
<li><p>Start the Docker daemon through systemd manager by running this command:</p>
<div class="highlight-bash notranslate"><div class="highlight"><pre><span></span>sudo<span class="w"> </span>systemctl<span class="w"> </span>start<span class="w"> </span>docker
</pre></div>
</div>
<p>If you want Docker to start automatically on boot, enable the
systemd service by running this command:</p>
<div class="highlight-bash notranslate"><div class="highlight"><pre><span></span>sudo<span class="w"> </span>systemctl<span class="w"> </span><span class="nb">enable</span><span class="w"> </span>docker
</pre></div>
</div>
</li>
<li><p>Finally, verify <strong class="command">docker</strong> has been installed by running this
command and checking the version output for both <em>client</em> and <em>server</em>:</p>
<div class="highlight-bash notranslate"><div class="highlight"><pre><span></span>sudo<span class="w"> </span>docker<span class="w"> </span>version
</pre></div>
</div>
</li>
</ol>
<p>Congratulations! At this point, you have a working installation of Docker
on Clear Linux OS. You are ready to start using container images on your system.</p>
</section>
<section id="integration-with-kata-containers-optional">
<h2><a class="toc-backref" href="#id5" role="doc-backlink">Integration with Kata Containers* (optional)</a><a class="headerlink" href="#integration-with-kata-containers-optional" title="Link to this heading"></a></h2>
<p><a class="reference external" href="https://katacontainers.io/">Kata Containers</a>, is an open source project aiming to increase security
of containers by using a hardware-backed virtual machine container runtime
rather than software namespace containers that are provided by the standard
Docker <em>runc</em> runtime.</p>
<p>Clear Linux OS provides easy integration of the <em>kata-runtime</em> with Docker.
More information on installing and using the <em>kata-runtime</em> may be found at <a class="reference internal" href="kata.html#kata"><span class="std std-ref">Kata Containers*</span></a>.</p>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>The remaining sections of this tutorial are standard to Docker setup
and configuration. If you are familiar with Docker basics, you do not
need to continue reading. The following sections are provided here for
sake of completeness.</p>
</div>
</section>
<section id="additional-docker-configuration">
<span id="id2"></span><h2><a class="toc-backref" href="#id6" role="doc-backlink">Additional Docker configuration</a><a class="headerlink" href="#additional-docker-configuration" title="Link to this heading"></a></h2>
<p>Perform additional Docker daemon configuration via a configuration file
typically located at <code class="file docutils literal notranslate"><span class="pre">/etc/docker/daemon.json</span></code>. Clear Linux OS features a
<a class="reference internal" href="../guides/clear/stateless.html#stateless"><span class="std std-ref">Stateless</span></a> system so the configuration file <code class="file docutils literal notranslate"><span class="pre">daemon.json</span></code> does
<em>NOT</em> exist by default.</p>
<ol class="arabic">
<li><p>Create the <code class="file docutils literal notranslate"><span class="pre">daemon.json</span></code> by running this command:</p>
<div class="highlight-bash notranslate"><div class="highlight"><pre><span></span>sudo<span class="w"> </span>touch<span class="w"> </span>/etc/docker/daemon.json
</pre></div>
</div>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>Refer to the <a class="reference external" href="https://docs.docker.com/engine/reference/commandline/dockerd/#daemon-configuration-file">Docker documentation on daemon configuration</a> for the
full list of available configuration options and examples.</p>
</div>
</li>
<li><p>For production systems, we follow Dockers recommendation to use the
<a class="reference external" href="https://docs.docker.com/storage/storagedriver/overlayfs-driver/">OverlayFS storage driver</a> <cite>overlay2</cite>, shown below:</p>
<div class="highlight-json notranslate"><div class="highlight"><pre><span></span><span class="p">{</span>
<span class="w"> </span><span class="nt">&quot;storage-driver&quot;</span><span class="p">:</span><span class="w"> </span><span class="s2">&quot;overlay2&quot;</span>
<span class="p">}</span>
</pre></div>
</div>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>A testing version is found in <a class="reference external" href="https://docs.docker.com/storage/storagedriver/device-mapper-driver/">Docker Device Mapper storage driver</a>.
If using this storage driver, a warning message may appear: “usage of
loopback devices is strongly discouraged for production use”.</p>
</div>
</li>
<li><p>Save and close <code class="file docutils literal notranslate"><span class="pre">daemon.json</span></code>.</p></li>
<li><p>Once youve made any required changes, be sure to restart the
Docker daemon through systemd manager by running this command:</p>
<div class="highlight-bash notranslate"><div class="highlight"><pre><span></span>sudo<span class="w"> </span>systemctl<span class="w"> </span>restart<span class="w"> </span>docker
</pre></div>
</div>
</li>
</ol>
</section>
<section id="pulling-and-running-an-image-from-docker-hub">
<h2><a class="toc-backref" href="#id7" role="doc-backlink">Pulling and running an image from Docker Hub*</a><a class="headerlink" href="#pulling-and-running-an-image-from-docker-hub" title="Link to this heading"></a></h2>
<p><a class="reference external" href="https://hub.docker.com/">Docker Hub</a> is a publicly available container image repository which
comes pre-configured with Docker. In the example below we will pull and run
an the official Docker image for nginx*, an open source reverse proxy server.</p>
<ol class="arabic">
<li><p>First, pull a container image from Docker Hub using the
<strong class="command">docker pull</strong> command. Download the latest nginx* Docker
container image by running this command:</p>
<div class="highlight-bash notranslate"><div class="highlight"><pre><span></span>sudo<span class="w"> </span>docker<span class="w"> </span>pull<span class="w"> </span>nginx
</pre></div>
</div>
</li>
<li><p>Create and launch a new container using the <strong class="command">docker run</strong>
command. Launch a nginx container by running this command:</p>
<div class="highlight-bash notranslate"><div class="highlight"><pre><span></span>sudo<span class="w"> </span>docker<span class="w"> </span>run<span class="w"> </span>--name<span class="w"> </span>test-nginx<span class="w"> </span>-d<span class="w"> </span>-p<span class="w"> </span><span class="m">8080</span>:80<span class="w"> </span>nginx
</pre></div>
</div>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>Below is an explanation of switches used in the command above. For
detailed <strong class="command">docker run</strong> switches and syntax, refer to the
<a class="reference external" href="https://docs.docker.com/">Docker Documentation</a> .</p>
<ul class="simple">
<li><p>The <em>name</em> switch lets you provide a friendly name to
target the container for future operations</p></li>
<li><p>The <em>-d</em> switch launches the container in the background</p></li>
<li><p>The <em>-p</em> switch allows the containers HTTP port (80) to be
accessible from the Clear Linux OS host on port 8080</p></li>
</ul>
</div>
</li>
<li><p>You can access the Welcome to Nginx! splash page running in the container
by browsing to http://127.0.0.1:8080 or by running this <strong class="command">curl</strong>
command from your Clear Linux OS machine:</p>
<div class="highlight-bash notranslate"><div class="highlight"><pre><span></span>curl<span class="w"> </span><span class="m">127</span>.0.0.1:8080
</pre></div>
</div>
</li>
<li><p>Finally, stop and delete the nginx container by running the
<strong class="command">docker stop</strong> and <strong class="command">docker rm</strong> commands.</p>
<div class="highlight-bash notranslate"><div class="highlight"><pre><span></span>sudo<span class="w"> </span>docker<span class="w"> </span>stop<span class="w"> </span>test-nginx
sudo<span class="w"> </span>docker<span class="w"> </span>rm<span class="w"> </span>test-nginx
</pre></div>
</div>
</li>
</ol>
<p>Congratulations! At this point, you have successfully pulled a nginx
container image from <a class="reference external" href="https://hub.docker.com/">Docker Hub</a> and have run an example container.</p>
</section>
<section id="creating-a-docker-swarm-cluster">
<h2><a class="toc-backref" href="#id8" role="doc-backlink">Creating a Docker swarm cluster</a><a class="headerlink" href="#creating-a-docker-swarm-cluster" title="Link to this heading"></a></h2>
<p>Clusters of Docker hosts are referred to as <em>swarms</em>.</p>
<p>The process in this tutorial can be repeated to install Docker on multiple
Clear Linux OS hosts with the intent to form a Docker swarm cluster.</p>
<p>The <a class="reference external" href="https://docs.docker.com/engine/swarm/key-concepts/">Docker documentation on swarm key concepts</a> and
<a class="reference external" href="https://docs.docker.com/engine/swarm/swarm-tutorial/create-swarm/">Docker documentation on creating a swarm</a> can be referenced
for further instructions on setting up a swarm.</p>
</section>
<section id="related-topics">
<h2><a class="toc-backref" href="#id9" role="doc-backlink">Related topics</a><a class="headerlink" href="#related-topics" title="Link to this heading"></a></h2>
<ul class="simple">
<li><p><a class="reference external" href="https://www.docker.com/">Docker Home</a></p></li>
<li><p><a class="reference external" href="https://docs.docker.com/">Docker Documentation</a></p></li>
<li><p><a class="reference external" href="https://hub.docker.com/">Docker Hub</a></p></li>
<li><p><a class="reference external" href="https://katacontainers.io/">Kata Containers</a></p></li>
</ul>
</section>
</section>
<div class="clearer"></div>
</div>
</div>
</div>
<div class="sphinxsidebar" role="navigation" aria-label="Main">
<div class="sphinxsidebarwrapper">
<p class="logo"><a href="../index.html">
<img class="logo" src="../_static/clearlinux.png" alt="Logo of Clear Linux* Project Docs"/>
</a></p>
<div>
<h3><a href="../index.html">Table of Contents</a></h3>
<ul>
<li><a class="reference internal" href="#">Docker*</a><ul>
<li><a class="reference internal" href="#prerequisites">Prerequisites</a></li>
<li><a class="reference internal" href="#install-the-containers-basic-bundle">Install the containers-basic bundle</a></li>
<li><a class="reference internal" href="#integration-with-kata-containers-optional">Integration with Kata Containers* (optional)</a></li>
<li><a class="reference internal" href="#additional-docker-configuration">Additional Docker configuration</a></li>
<li><a class="reference internal" href="#pulling-and-running-an-image-from-docker-hub">Pulling and running an image from Docker Hub*</a></li>
<li><a class="reference internal" href="#creating-a-docker-swarm-cluster">Creating a Docker swarm cluster</a></li>
<li><a class="reference internal" href="#related-topics">Related topics</a></li>
</ul>
</li>
</ul>
</div>
<div>
<h4>Previous topic</h4>
<p class="topless"><a href="broadcom.html"
title="previous chapter">Broadcom* Drivers</a></p>
</div>
<div>
<h4>Next topic</h4>
<p class="topless"><a href="flatpak.html"
title="next chapter">Flatpak*</a></p>
</div>
<div role="note" aria-label="source link">
<h3>This Page</h3>
<ul class="this-page-menu">
<li><a href="../_sources/tutorials/docker.rst.txt"
rel="nofollow">Show Source</a></li>
</ul>
</div>
<search id="searchbox" style="display: none" role="search">
<h3 id="searchlabel">Quick search</h3>
<div class="searchformwrapper">
<form class="search" action="../search.html" method="get">
<input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
<input type="submit" value="Go" />
</form>
</div>
</search>
<script>document.getElementById('searchbox').style.display = "block"</script>
</div>
</div>
<div class="clearer"></div>
</div>
<div class="related" role="navigation" aria-label="Related">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="../genindex.html" title="General Index"
>index</a></li>
<li class="right" >
<a href="flatpak.html" title="Flatpak*"
>next</a> |</li>
<li class="right" >
<a href="broadcom.html" title="Broadcom* Drivers"
>previous</a> |</li>
<li class="nav-item nav-item-0"><a href="../index.html">Documentation for Clear Linux* project</a> &#187;</li>
<li class="nav-item nav-item-1"><a href="index.html" >Tutorials</a> &#187;</li>
<li class="nav-item nav-item-this"><a href="">Docker*</a></li>
</ul>
</div>
<div class="footer" role="contentinfo">
&#169; Copyright 2022 Intel Corporation. All Rights Reserved..
Last updated on Nov 04, 2024.
Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 8.1.3.
</div>
</body>
</html>