<div id="docs-body">
 <div class="section">
  <div class="titlepage">
   <div>
    <div>
     <h4 class="title">
      <a name="docker-mysql-getting-started">
      </a>
      2.5.6.1 Basic Steps for MySQL Server Deployment with Docker
     </h4>
    </div>
   </div>
  </div>
  <div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;">
   <div class="admon-title">
    Warning
   </div>
   <p>
    The MySQL Docker images maintained by the MySQL team are built
          specifically for Linux platforms. Other platforms are not
          supported, and users using these MySQL Docker images on them
          are doing so at their own risk. See
    <a class="link" href="deploy-mysql-nonlinux-docker.html" title="2.5.6.3 Deploying MySQL on Windows and Other Non-Linux Platforms with Docker">
     the discussion
          here
    </a>
    for some known limitations for running these
          containers on non-Linux operating systems.
   </p>
  </div>
  <div class="itemizedlist">
   <ul class="itemizedlist" style="list-style-type: disc; ">
    <li class="listitem">
     <p>
      <a class="xref" href="docker-mysql-getting-started.html#docker-download-image" title="Downloading a MySQL Server Docker Image">
       Downloading a MySQL Server Docker Image
      </a>
     </p>
    </li>
    <li class="listitem">
     <p>
      <a class="xref" href="docker-mysql-getting-started.html#docker-starting-mysql-server" title="Starting a MySQL Server Instance">
       Starting a MySQL Server Instance
      </a>
     </p>
    </li>
    <li class="listitem">
     <p>
      <a class="xref" href="docker-mysql-getting-started.html#docker-connecting-within-container" title="Connecting to MySQL Server from within the Container">
       Connecting to MySQL Server from within the Container
      </a>
     </p>
    </li>
    <li class="listitem">
     <p>
      <a class="xref" href="docker-mysql-getting-started.html#docker-shell-access" title="Container Shell Access">
       Container Shell Access
      </a>
     </p>
    </li>
    <li class="listitem">
     <p>
      <a class="xref" href="docker-mysql-getting-started.html#docker-stopping-deleting" title="Stopping and Deleting a MySQL Container">
       Stopping and Deleting a MySQL Container
      </a>
     </p>
    </li>
    <li class="listitem">
     <p>
      <a class="xref" href="docker-mysql-getting-started.html#docker-upgrading" title="Upgrading a MySQL Server Container">
       Upgrading a MySQL Server Container
      </a>
     </p>
    </li>
    <li class="listitem">
     <p>
      <a class="xref" href="docker-mysql-getting-started.html#docker-more-topics" title="More Topics on Deploying MySQL Server with Docker">
       More Topics on Deploying MySQL Server with Docker
      </a>
     </p>
    </li>
   </ul>
  </div>
  <h5>
   <a name="docker-download-image">
   </a>
   Downloading a MySQL Server Docker Image
  </h5>
  <div class="important" style="margin-left: 0.5in; margin-right: 0.5in;">
   <div class="admon-title">
    Important
   </div>
   <p>
    <span class="emphasis">
     <em>
      For users of MySQL Enterprise Edition
     </em>
    </span>
    : A subscription is
          required to use the Docker images for MySQL Enterprise Edition. Subscriptions
          work by a Bring Your Own License model; see
    <a class="ulink" href="https://www.mysql.com/buy-mysql/" target="_blank">
     How to Buy MySQL
          Products and Services
    </a>
    for details.
   </p>
  </div>
  <p>
   Downloading the server image in a separate step is not strictly
        necessary; however, performing this step before you create your
        Docker container ensures your local image is up to date. To
        download the MySQL Community Edition image from the
   <a class="ulink" href="https://container-registry.oracle.com/" target="_blank">
    Oracle
        Container Registry (OCR)
   </a>
   , run this command:
  </p>
  <div class="copytoclipboard-wrapper">
   <pre class="programlisting one-line language-terminal"><div class="docs-select-all right" id="sa76241207"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-terminal">docker pull container-registry<span class="token punctuation">.</span>oracle<span class="token punctuation">.</span>com/mysql/community-server<span class="token punctuation">:</span><em class="replaceable">tag</em></code></pre>
  </div>
  <p>
   The
   <em class="replaceable">
    <code>
     tag
    </code>
   </em>
   is the label for the image
        version you want to pull (for example,
   <code class="literal">
    8.4
   </code>
   , or
   <code class="literal">
    9.1
   </code>
   , or
   <code class="literal">
    latest
   </code>
   ). If
   <strong class="userinput">
    <code>
     :
     <em class="replaceable">
      <code>
       tag
      </code>
     </em>
    </code>
   </strong>
   is
        omitted, the
   <code class="literal">
    latest
   </code>
   label is used, and the
        image for the latest GA release (which is the latest innovation
        release) of MySQL Community Server is downloaded.
  </p>
  <p>
   To download the MySQL Enterprise Edition image from the OCR, you need to first
        accept the license agreement on the OCR and log in to the
        container repository with your Docker client. Follow these
        steps:
  </p>
  <div class="itemizedlist">
   <ul class="itemizedlist" style="list-style-type: disc; ">
    <li class="listitem">
     <p>
      Visit the OCR at
      <a class="ulink" href="https://container-registry.oracle.com/" target="_blank">
       https://container-registry.oracle.com/
      </a>
      and
            choose
      <span class="guiicon">
       MySQL
      </span>
      .
     </p>
    </li>
    <li class="listitem">
     <p>
      Under the list of MySQL repositories, choose
      <code class="literal">
       enterprise-server
      </code>
      .
     </p>
    </li>
    <li class="listitem">
     <p>
      If you have not signed in to the OCR yet, click the
      <span class="guibutton">
       Sign in
      </span>
      button on the right of the
            page, and then enter your Oracle account credentials when
            prompted to.
     </p>
    </li>
    <li class="listitem">
     <p>
      Follow the instructions on the right of the page to accept
            the license agreement.
     </p>
    </li>
    <li class="listitem">
     <p>
      Log in to the OCR with your container client using, for
            example, the
      <code class="literal">
       docker login
      </code>
      command:
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting language-terminal"><div class="docs-select-all right" id="sa48494576"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-terminal"><span class="token comment" spellcheck="true"># docker login container-registry.oracle.com </span>
Username<span class="token punctuation">:</span> <em class="replaceable">Oracle-Account-ID</em>
Password<span class="token punctuation">:</span> <em class="replaceable">password</em>
Login successful<span class="token punctuation">.</span></code></pre>
     </div>
    </li>
   </ul>
  </div>
  <p>
   Download the Docker image for MySQL Enterprise Edition from the OCR with this
        command:
  </p>
  <div class="copytoclipboard-wrapper">
   <pre class="programlisting one-line language-terminal"><div class="docs-select-all right" id="sa30168128"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-terminal">docker pull  container-registry<span class="token punctuation">.</span>oracle<span class="token punctuation">.</span>com/mysql/enterprise-server<span class="token punctuation">:</span><em class="replaceable">tag</em></code></pre>
  </div>
  <p>
   To download the MySQL Enterprise Edition image from
   <a class="ulink" href="https://support.oracle.com/" target="_blank">
    My Oracle
        Support
   </a>
   website, go onto the website, sign in to your
        Oracle account, and perform these steps once you are on the
        landing page:
  </p>
  <p>
  </p>
  <div class="itemizedlist">
   <ul class="itemizedlist" style="list-style-type: disc; ">
    <li class="listitem">
     <p>
      Select the
      <span class="guimenu">
       Patches and Updates
      </span>
      tab.
     </p>
    </li>
    <li class="listitem">
     <p>
      Go to the
      <span class="guilabel">
       Patch Search
      </span>
      region and, on
              the
      <span class="guilabel">
       Search
      </span>
      tab, switch to the
      <span class="guilabel">
       Product or Family (Advanced)
      </span>
      subtab.
     </p>
    </li>
    <li class="listitem">
     <p>
      Enter
      <span class="quote">
       “
       <span class="quote">
        MySQL Server
       </span>
       ”
      </span>
      for the
      <span class="guimenuitem">
       Product
      </span>
      field, and the desired
              version number in the
      <span class="guimenuitem">
       Release
      </span>
      field.
     </p>
    </li>
    <li class="listitem">
     <p>
      Use the dropdowns for additional filters to select
      <span class="guimenuitem">
       Description
      </span>
      —
      <span class="guimenuitem">
       contains
      </span>
      ,
              and enter
      <span class="quote">
       “
       <span class="quote">
        Docker
       </span>
       ”
      </span>
      in the text field.
     </p>
     <p>
      The following figure shows the search settings for the
              MySQL Enterprise Edition image for MySQL Server 8.0:
     </p>
     <div class="mediaobject">
      <img alt="Diagram showing search settings for MySQL Enterprise image" src="images/docker-search2.png" style="width: 100%; max-width: 922px;"/>
     </div>
    </li>
    <li class="listitem">
     <p>
      Click the
      <span class="guibutton">
       Search
      </span>
      button and, from
              the result list, select the version you want, and click
              the
      <span class="guibutton">
       Download
      </span>
      button.
     </p>
    </li>
    <li class="listitem">
     <p>
      In the
      <span class="guilabel">
       File Download
      </span>
      dialogue box
              that appears, click and download the
      <code class="filename">
       .zip
      </code>
      file for the Docker image.
     </p>
    </li>
   </ul>
  </div>
  <p>
   Unzip the downloaded
   <code class="filename">
    .zip
   </code>
   archive to obtain
        the tarball inside
        (
   <code class="filename">
    mysql-enterprise-server-
    <em class="replaceable">
     <code>
      version
     </code>
    </em>
    .tar
   </code>
   ),
        and then load the image by running this command:
  </p>
  <div class="copytoclipboard-wrapper">
   <pre class="programlisting one-line language-simple"><div class="docs-select-all right" id="sa45468036"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-simple">docker load <span class="token operator">-</span>i mysql<span class="token operator">-</span>enterprise<span class="token operator">-</span>server<span class="token operator">-</span><em class="replaceable">version</em><span class="token punctuation">.</span>tar</code></pre>
  </div>
  <p>
   You can list downloaded Docker images with this command:
  </p>
  <div class="copytoclipboard-wrapper">
   <pre class="programlisting language-terminal"><div class="docs-select-all right" id="sa52281985"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-terminal"><span class="token prompt">$&gt; </span><span class="token command">docker</span> images
REPOSITORY                                             TAG       IMAGE ID       CREATED        SIZE
container-registry<span class="token punctuation">.</span>oracle<span class="token punctuation">.</span>com/mysql/community-server   latest    1d9c2219ff69   2 months ago   496MB</code></pre>
  </div>
  <h5>
   <a name="docker-starting-mysql-server">
   </a>
   Starting a MySQL Server Instance
  </h5>
  <p>
   To start a new Docker container for a MySQL Server, use the
        following command:
  </p>
  <div class="copytoclipboard-wrapper">
   <pre class="programlisting one-line language-terminal"><div class="docs-select-all right" id="sa12619065"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-terminal">docker run <span class="token constant">--name</span><span class="token attr-value"><span class="token punctuation">=</span><em class="replaceable">container_name</em></span>  <span class="token property">--restart</span> on-failure <span class="token property">-d</span> <em class="replaceable">image_name</em><span class="token punctuation">:</span><em class="replaceable">tag</em></code></pre>
  </div>
  <p>
   <em class="replaceable">
    <code>
     image_name
    </code>
   </em>
   is the name of the image
        to be used to start the container; see
   <a class="xref" href="docker-mysql-getting-started.html#docker-download-image" title="Downloading a MySQL Server Docker Image">
    Downloading a MySQL Server Docker Image
   </a>
   for more information.
  </p>
  <p>
   The
   <code class="option">
    --name
   </code>
   option, for supplying a custom name
        for your server container, is optional; if no container name is
        supplied, a random one is generated.
  </p>
  <p>
   The
   <code class="option">
    --restart
   </code>
   option is for configuring the
   <a class="ulink" href="https://docs.docker.com/config/containers/start-containers-automatically/" target="_blank">
    restart
        policy
   </a>
   for your container; it should be set to the value
   <code class="literal">
    on-failure
   </code>
   , to enable support for server
        restart within a client session (which happens, for example,
        when the
   <a class="link" href="restart.html" title="15.7.8.8 RESTART Statement">
    RESTART
   </a>
   statement is
        executed by a client or during the configuration of an
        InnoDB Cluster instance). With the support for restart
        enabled, issuing a restart within a client session causes the
        server and the container to stop and then restart.
  </p>
  <p>
   For example, to start a new Docker container for the MySQL
        Community Server, use this command:
  </p>
  <div class="copytoclipboard-wrapper">
   <pre class="programlisting one-line language-terminal"><div class="docs-select-all right" id="sa7920167"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-terminal">docker run <span class="token constant">--name</span><span class="token attr-value"><span class="token punctuation">=</span>mysql1</span> <span class="token property">--restart</span> on-failure <span class="token property">-d</span> container-registry<span class="token punctuation">.</span>oracle<span class="token punctuation">.</span>com/mysql/community-server<span class="token punctuation">:</span>latest</code></pre>
  </div>
  <p>
   To start a new Docker container for the MySQL Enterprise Server
        with a Docker image downloaded from the OCR, use this command:
  </p>
  <div class="copytoclipboard-wrapper">
   <pre class="programlisting one-line language-terminal"><div class="docs-select-all right" id="sa42016940"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-terminal">docker run <span class="token constant">--name</span><span class="token attr-value"><span class="token punctuation">=</span>mysql1</span> <span class="token property">--restart</span> on-failure <span class="token property">-d</span> container-registry<span class="token punctuation">.</span>oracle<span class="token punctuation">.</span>com/mysql/enterprise-server<span class="token punctuation">:</span>latest</code></pre>
  </div>
  <p>
   To start a new Docker container for the MySQL Enterprise Server
        with a Docker image downloaded from My Oracle Support, use this
        command:
  </p>
  <div class="copytoclipboard-wrapper">
   <pre class="programlisting one-line language-terminal"><div class="docs-select-all right" id="sa77559957"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-terminal">docker run <span class="token constant">--name</span><span class="token attr-value"><span class="token punctuation">=</span>mysql1</span> <span class="token property">--restart</span> on-failure <span class="token property">-d</span> mysql/enterprise-server<span class="token punctuation">:</span>latest</code></pre>
  </div>
  <p>
   If the Docker image of the specified name and tag has not been
        downloaded by an earlier
   <span class="command">
    <strong>
     docker pull
    </strong>
   </span>
   or
   <span class="command">
    <strong>
     docker run
    </strong>
   </span>
   command, the image is now
        downloaded. Initialization for the container begins, and the
        container appears in the list of running containers when you run
        the
   <span class="command">
    <strong>
     docker ps
    </strong>
   </span>
   command. For example:
  </p>
  <div class="copytoclipboard-wrapper">
   <pre class="programlisting language-terminal"><div class="docs-select-all right" id="sa79282230"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-terminal"><span class="token prompt">$&gt; </span><span class="token command">docker</span> ps
CONTAINER ID   IMAGE                                                         COMMAND                  CREATED          STATUS                    PORTS                       NAMES
4cd4129b3211   container-registry<span class="token punctuation">.</span>oracle<span class="token punctuation">.</span>com/mysql/community-server<span class="token punctuation">:</span>latest   <span class="token atrule">"/entrypoint.sh mysq…"</span>   8 seconds ago    Up 7 seconds <span class="token punctuation">(</span>health<span class="token punctuation">:</span> starting<span class="token punctuation">)</span>   3306/tcp<span class="token punctuation">,</span> 33060-33061/tcp   mysql1</code></pre>
  </div>
  <p>
   The container initialization might take some time. When the
        server is ready for use, the
   <code class="literal">
    STATUS
   </code>
   of the
        container in the output of the
   <span class="command">
    <strong>
     docker ps
    </strong>
   </span>
   command changes from
   <code class="literal">
    (health: starting)
   </code>
   to
   <code class="literal">
    (healthy)
   </code>
   .
  </p>
  <p>
   The
   <code class="option">
    -d
   </code>
   option used in the
   <span class="command">
    <strong>
     docker
        run
    </strong>
   </span>
   command above makes the container run in the
        background. Use this command to monitor the output from the
        container:
  </p>
  <div class="copytoclipboard-wrapper">
   <pre class="programlisting one-line language-terminal"><div class="docs-select-all right" id="sa55600268"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-terminal">docker logs mysql1</code></pre>
  </div>
  <p>
  </p>
  <p>
   Once initialization is finished, the command's output is going
        to contain the random password generated for the root user;
        check the password with, for example, this command:
  </p>
  <div class="copytoclipboard-wrapper">
   <pre class="programlisting language-terminal"><div class="docs-select-all right" id="sa3591565"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-terminal"><span class="token prompt">$&gt; </span><span class="token command">docker</span> logs mysql1 2&gt;&amp;1 | grep GENERATED
GENERATED ROOT PASSWORD<span class="token punctuation">:</span> Axegh3kAJyDLaRuBemecis&amp;EShOs</code></pre>
  </div>
  <p>
  </p>
  <h5>
   <a name="docker-connecting-within-container">
   </a>
   Connecting to MySQL Server from within the Container
  </h5>
  <p>
   Once the server is ready, you can run the
   <a class="link" href="mysql.html" title="6.5.1 mysql — The MySQL Command-Line Client">
    <span class="command">
     <strong>
      mysql
     </strong>
    </span>
   </a>
   client within the MySQL Server
        container you just started, and connect it to the MySQL Server.
        Use the
   <span class="command">
    <strong>
     docker exec -it
    </strong>
   </span>
   command to start a
   <a class="link" href="mysql.html" title="6.5.1 mysql — The MySQL Command-Line Client">
    <span class="command">
     <strong>
      mysql
     </strong>
    </span>
   </a>
   client inside the Docker container you
        have started, like the following:
  </p>
  <div class="copytoclipboard-wrapper">
   <pre class="programlisting one-line language-terminal"><div class="docs-select-all right" id="sa80830888"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-terminal">docker exec <span class="token property">-it</span> mysql1 mysql <span class="token property">-uroot</span> <span class="token property">-p</span></code></pre>
  </div>
  <p>
   When asked, enter the generated root password (see the last step
        in
   <a class="xref" href="docker-mysql-getting-started.html#docker-starting-mysql-server" title="Starting a MySQL Server Instance">
    Starting a MySQL Server Instance
   </a>
   above on how to find the password). Because the
   <a class="link" href="docker-mysql-more-topics.html#docker_var_mysql_onetime_password">
    <code class="option">
     MYSQL_ONETIME_PASSWORD
    </code>
   </a>
   option is true by default, after you have connected a
   <a class="link" href="mysql.html" title="6.5.1 mysql — The MySQL Command-Line Client">
    <span class="command">
     <strong>
      mysql
     </strong>
    </span>
   </a>
   client to the server, you must reset
        the server root password by issuing this statement:
  </p>
  <div class="copytoclipboard-wrapper">
   <pre class="programlisting one-line language-terminal"><div class="docs-select-all right" id="sa8560179"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-terminal"><span class="token prompt">mysql&gt;</span><span class="token command"> ALTER</span> USER <span class="token atrule">'root'</span>@<span class="token atrule">'localhost'</span> IDENTIFIED BY <span class="token atrule">'<em class="replaceable">password</em>'</span><span class="token punctuation">;</span></code></pre>
  </div>
  <p>
   Substitute
   <em class="replaceable">
    <code>
     password
    </code>
   </em>
   with the password
        of your choice. Once the password is reset, the server is ready
        for use.
  </p>
  <h5>
   <a name="docker-shell-access">
   </a>
   Container Shell Access
  </h5>
  <p>
   To have shell access to your MySQL Server container, use the
   <span class="command">
    <strong>
     docker exec -it
    </strong>
   </span>
   command to start a bash shell
        inside the container:
  </p>
  <div class="copytoclipboard-wrapper">
   <pre class="programlisting language-terminal"><div class="docs-select-all right" id="sa7660649"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-terminal"><span class="token prompt">$&gt; </span><span class="token command">docker</span> exec <span class="token property">-it</span> mysql1 bash
bash-4<span class="token punctuation">.</span>2<span class="token comment" spellcheck="true">#</span></code></pre>
  </div>
  <p>
   You can then run Linux commands inside the container. For
        example, to view contents in the server's data directory inside
        the container, use this command:
  </p>
  <div class="copytoclipboard-wrapper">
   <pre class="programlisting language-terminal"><div class="docs-select-all right" id="sa98929954"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-terminal">bash-4<span class="token punctuation">.</span>2<span class="token comment" spellcheck="true"># ls /var/lib/mysql</span>
auto<span class="token punctuation">.</span>cnf    ca<span class="token punctuation">.</span>pem	     client-key<span class="token punctuation">.</span>pem  ib_logfile0  ibdata1  mysql       mysql<span class="token punctuation">.</span>sock<span class="token punctuation">.</span>lock	   private_key<span class="token punctuation">.</span>pem  server-cert<span class="token punctuation">.</span>pem  sys
ca-key<span class="token punctuation">.</span>pem  client-cert<span class="token punctuation">.</span>pem  ib_buffer_pool  ib_logfile1  ibtmp1   mysql<span class="token punctuation">.</span>sock  performance_schema  public_key<span class="token punctuation">.</span>pem   server-key<span class="token punctuation">.</span>pem</code></pre>
  </div>
  <h5>
   <a name="docker-stopping-deleting">
   </a>
   Stopping and Deleting a MySQL Container
  </h5>
  <p>
   To stop the MySQL Server container we have created, use this
        command:
  </p>
  <div class="copytoclipboard-wrapper">
   <pre class="programlisting one-line language-terminal"><div class="docs-select-all right" id="sa80749013"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-terminal">docker stop mysql1</code></pre>
  </div>
  <p>
   <span class="command">
    <strong>
     docker stop
    </strong>
   </span>
   sends a SIGTERM signal to the
   <a class="link" href="mysqld.html" title="6.3.1 mysqld — The MySQL Server">
    <span class="command">
     <strong>
      mysqld
     </strong>
    </span>
   </a>
   process, so that the server is shut
        down gracefully.
  </p>
  <p>
   Also notice that when the main process of a container
        (
   <a class="link" href="mysqld.html" title="6.3.1 mysqld — The MySQL Server">
    <span class="command">
     <strong>
      mysqld
     </strong>
    </span>
   </a>
   in the case of a MySQL Server
        container) is stopped, the Docker container stops automatically.
  </p>
  <p>
   To start the MySQL Server container again:
  </p>
  <div class="copytoclipboard-wrapper">
   <pre class="programlisting one-line language-terminal"><div class="docs-select-all right" id="sa99871467"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-terminal">docker start mysql1</code></pre>
  </div>
  <p>
   To stop and start again the MySQL Server container with a single
        command:
  </p>
  <div class="copytoclipboard-wrapper">
   <pre class="programlisting one-line language-terminal"><div class="docs-select-all right" id="sa76469827"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-terminal">docker restart mysql1</code></pre>
  </div>
  <p>
   To delete the MySQL container, stop it first, and then use the
   <span class="command">
    <strong>
     docker rm
    </strong>
   </span>
   command:
  </p>
  <div class="copytoclipboard-wrapper">
   <pre class="programlisting one-line language-terminal"><div class="docs-select-all right" id="sa73820979"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-terminal">docker stop mysql1</code></pre>
  </div>
  <div class="copytoclipboard-wrapper">
   <pre class="programlisting one-line language-terminal"><div class="docs-select-all right" id="sa78341922"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-terminal">docker rm mysql1</code></pre>
  </div>
  <p>
   If you want the
   <a class="link" href="docker-mysql-more-topics.html#docker-persisting-data-configuration" title="Persisting Data and Configuration Changes">
    Docker
        volume for the server's data directory
   </a>
   to be deleted at
        the same time, add the
   <code class="literal">
    -v
   </code>
   option to the
   <span class="command">
    <strong>
     docker rm
    </strong>
   </span>
   command.
  </p>
  <h5>
   <a name="docker-upgrading">
   </a>
   Upgrading a MySQL Server Container
  </h5>
  <div class="important" style="margin-left: 0.5in; margin-right: 0.5in;">
   <div class="admon-title">
    Important
   </div>
   <div class="itemizedlist">
    <ul class="itemizedlist" style="list-style-type: disc; ">
     <li class="listitem">
      <p>
       Before performing any upgrade to MySQL, follow carefully
              the instructions in
       <a class="xref" href="upgrading.html" title="Chapter 3 Upgrading MySQL">
        Chapter 3,
        <i>
         Upgrading MySQL
        </i>
       </a>
       . Among
              other instructions discussed there, it is especially
              important to back up your database before the upgrade.
      </p>
     </li>
     <li class="listitem">
      <p>
       The instructions in this section require that the server's
              data and configuration have been persisted on the host.
              See
       <a class="xref" href="docker-mysql-more-topics.html#docker-persisting-data-configuration" title="Persisting Data and Configuration Changes">
        Persisting Data and Configuration Changes
       </a>
       for details.
      </p>
     </li>
    </ul>
   </div>
  </div>
  <p>
   Follow these steps to upgrade a Docker installation of MySQL
        8.4 to 9.1:
  </p>
  <div class="itemizedlist">
   <ul class="itemizedlist" style="list-style-type: disc; ">
    <li class="listitem">
     <p>
      Stop the MySQL 8.4 server (container name
            is
      <code class="literal">
       mysql84
      </code>
      in
            this example):
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting one-line language-terminal"><div class="docs-select-all right" id="sa70900139"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-terminal">docker stop mysql84</code></pre>
     </div>
    </li>
    <li class="listitem">
     <p>
      Download the MySQL 9.1 Server Docker
            image. See instructions in
      <a class="xref" href="docker-mysql-getting-started.html#docker-download-image" title="Downloading a MySQL Server Docker Image">
       Downloading a MySQL Server Docker Image
      </a>
      . Make sure you use
            the right tag for MySQL 9.1.
     </p>
    </li>
    <li class="listitem">
     <p>
      Start a new MySQL 9.1 Docker
            container (named
      <code class="literal">
       mysql91
      </code>
      in
            this example) with the old server data and configuration
            (with proper modifications if needed—see
      <a class="xref" href="upgrading.html" title="Chapter 3 Upgrading MySQL">
       Chapter 3,
       <i>
        Upgrading MySQL
       </i>
      </a>
      ) that have been
            persisted on the host (by
      <a class="ulink" href="https://docs.docker.com/engine/reference/commandline/service_create/#add-bind-mounts-or-volumes" target="_blank">
       bind-mounting
      </a>
      in this example). For the MySQL Community Server, run this
            command:
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting language-terminal"><div class="docs-select-all right" id="sa2812172"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-terminal">docker run <span class="token constant">--name</span><span class="token attr-value"><span class="token punctuation">=</span>mysql84</span> \
   <span class="token property">--mount</span> type<span class="token attr-value"><span class="token punctuation">=</span>bind,src=/path</span><span class="token constant">-on-host-machine/my.cnf,dst</span><span class="token attr-value"><span class="token punctuation">=</span>/etc/my.cnf</span> \
   <span class="token property">--mount</span> type<span class="token attr-value"><span class="token punctuation">=</span>bind,src=/path</span><span class="token constant">-on-host-machine/datadir,dst</span><span class="token attr-value"><span class="token punctuation">=</span>/var/lib/mysql</span> \
   <span class="token property">-d</span> container-registry<span class="token punctuation">.</span>oracle<span class="token punctuation">.</span>com/mysql/community-server<span class="token punctuation">:</span>9<span class="token punctuation">.</span>1</code></pre>
     </div>
     <p>
      If needed, adjust
      <code class="literal">
       container-registry.oracle.com/mysql/community-server
      </code>
      to the correct image name—for example, replace it with
      <code class="literal">
       container-registry.oracle.com/mysql/enterprise-server
      </code>
      for MySQL Enterprise Edition images downloaded from the OCR, or
      <code class="literal">
       mysql/enterprise-server
      </code>
      for MySQL Enterprise Edition images
            downloaded from My Oracle Support.
     </p>
    </li>
    <li class="listitem">
     <p>
      Wait for the server to finish startup. You can check the
            status of the server using the
      <span class="command">
       <strong>
        docker ps
       </strong>
      </span>
      command (see
      <a class="xref" href="docker-mysql-getting-started.html#docker-starting-mysql-server" title="Starting a MySQL Server Instance">
       Starting a MySQL Server Instance
      </a>
      for how to do that).
     </p>
    </li>
   </ul>
  </div>
  <p>
   Follow the same steps for upgrading within the
        9.1 series (that is, from release
        9.1.
   <em class="replaceable">
    <code>
     x
    </code>
   </em>
   to
        9.1.
   <em class="replaceable">
    <code>
     y
    </code>
   </em>
   ): stop
        the original container, and start a new one with a newer image
        on the old server data and configuration. If you used the
        9.1 or the
   <code class="literal">
    latest
   </code>
   tag
        when starting your original container and there is now a new
        MySQL 9.1 release you want to upgrade to
        it, you must first pull the image for the new release with the
        command:
  </p>
  <div class="copytoclipboard-wrapper">
   <pre class="programlisting one-line language-simple"><div class="docs-select-all right" id="sa2580187"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-simple">docker pull container<span class="token operator">-</span>registry<span class="token punctuation">.</span>oracle<span class="token punctuation">.</span>com<span class="token operator">/</span>mysql<span class="token operator">/</span>community<span class="token operator">-</span>server<span class="token operator">:</span>9<span class="token punctuation">.</span>1</code></pre>
  </div>
  <p>
   You can then upgrade by starting a
   <span class="emphasis">
    <em>
     new
    </em>
   </span>
   container with the same tag on the old data and configuration
        (adjust the image name if you are using the MySQL Enterprise Edition; see
   <a class="xref" href="docker-mysql-getting-started.html#docker-download-image" title="Downloading a MySQL Server Docker Image">
    Downloading a MySQL Server Docker Image
   </a>
   ):
  </p>
  <div class="copytoclipboard-wrapper">
   <pre class="programlisting language-terminal"><div class="docs-select-all right" id="sa77906451"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-terminal">docker run <span class="token constant">--name</span><span class="token attr-value"><span class="token punctuation">=</span>mysql84new</span> \
   <span class="token property">--mount</span> type<span class="token attr-value"><span class="token punctuation">=</span>bind,src=/path</span><span class="token constant">-on-host-machine/my.cnf,dst</span><span class="token attr-value"><span class="token punctuation">=</span>/etc/my.cnf</span> \
   <span class="token property">--mount</span> type<span class="token attr-value"><span class="token punctuation">=</span>bind,src=/path</span><span class="token constant">-on-host-machine/datadir,dst</span><span class="token attr-value"><span class="token punctuation">=</span>/var/lib/mysql</span> \
<span class="token property">-d</span> container-registry<span class="token punctuation">.</span>oracle<span class="token punctuation">.</span>com/mysql/community-server<span class="token punctuation">:</span>9<span class="token punctuation">.</span>1</code></pre>
  </div>
  <h5>
   <a name="docker-more-topics">
   </a>
   More Topics on Deploying MySQL Server with Docker
  </h5>
  <p>
   For more topics on deploying MySQL Server with Docker like
        server configuration, persisting data and configuration, server
        error log, and container environment variables, see
   <a class="xref" href="docker-mysql-more-topics.html" title="2.5.6.2 More Topics on Deploying MySQL Server with Docker">
    Section 2.5.6.2, “More Topics on Deploying MySQL Server with Docker”
   </a>
   .
  </p>
 </div>
 <br/>
</div>
