blob: dc56a1231af36d856b89b01cd2b2adfb97d2ee36 [file] [log] [blame]
<!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">
<meta name="generator" content="Asciidoctor 2.0.18">
<link rel="icon" type="image/png" href="images/favicon.png">
<title>Docker</title>
<link rel="stylesheet" href="css/asciidoctor.css">
<link rel="stylesheet" href="css/font-awesome.css">
<link rel="stylesheet" href="css/rouge-github.css">
</head>
<body class="book toc2 toc-left">
<div id="header">
<h1>Docker</h1>
<div id="toc" class="toc2">
<div id="toctitle"><a href="index.html">User Manual for 2.32.0</a></div>
<ul class="sectlevel1">
<li><a href="#official-images">1. Official Images</a></li>
<li><a href="#build-your-own-image">2. Build your own Image</a>
<ul class="sectlevel2">
<li><a href="#using-a-local-release">2.1. Using a Local Release</a></li>
<li><a href="#using-an-official-apache-release">2.2. Using an Official Apache Release</a></li>
<li><a href="#customizing-the-image">2.3. Customizing the Image</a></li>
</ul>
</li>
</ul>
</div>
</div>
<div id="content">
<div id="preamble">
<div class="sectionbody">
<div class="paragraph">
<p>One of the simplest ways to get started with ActiveMQ Artemis is by using one of our Docker images.</p>
</div>
</div>
</div>
<div class="sect1">
<h2 id="official-images"><a class="anchor" href="#official-images"></a><a class="link" href="#official-images">1. Official Images</a></h2>
<div class="sectionbody">
<div class="paragraph">
<p>Official <a href="https://www.docker.com/">Docker</a> images are <a href="https://hub.docker.com/r/apache/activemq-artemis/tags">available on dockerhub</a>.
Images are pushed along with all the other distribution artifacts for every release.
The fastest, simplest way to get started is with this command which will create and start a detached container named <code>mycontainer</code>, expose the main messaging port (i.e. <code>61616</code>) and HTTP port (i.e. <code>8161</code>), and remove it when it terminates:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="rouge highlight nowrap"><code data-lang="console"><span class="gp">$</span><span class="w"> </span>docker run <span class="nt">--detach</span> <span class="nt">--name</span> mycontainer <span class="nt">-p</span> 61616:61616 <span class="nt">-p</span> 8161:8161 <span class="nt">--rm</span> apache/activemq-artemis:latest-alpine</code></pre>
</div>
</div>
<div class="paragraph">
<p>Once the broker starts you can open the <a href="management-console.html">web management console</a> at <a href="http://localhost:8161" class="bare">http://localhost:8161</a> and log in with the default username &amp; password <code>artemis</code>.</p>
</div>
<div class="paragraph">
<p>You can also use the <code>shell</code> command to interact with the running broker using the default username &amp; password <code>artemis</code>, e.g.:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="rouge highlight nowrap"><code data-lang="console"><span class="gp">$</span><span class="w"> </span>docker <span class="nb">exec</span> <span class="nt">-it</span> mycontainer /var/lib/artemis-instance/bin/artemis shell <span class="nt">--user</span> artemis <span class="nt">--password</span> artemis</code></pre>
</div>
</div>
<div class="paragraph">
<p>Using the <code>shell</code> command you can execute basic tasks like creating &amp; deleting addresses and queues, sending and browsing messages, viewing queue statistics, etc.
See the <a href="using-cli.html#command-line-interface">Command Line Interface</a> chapter for more details.</p>
</div>
<div class="paragraph">
<p>You can view the container&#8217;s logs using:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="rouge highlight nowrap"><code data-lang="console"><span class="gp">$</span><span class="w"> </span>docker logs <span class="nt">-f</span> mycontainer</code></pre>
</div>
</div>
<div class="paragraph">
<p>Stop the container using:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="rouge highlight nowrap"><code data-lang="console"><span class="gp">$</span><span class="w"> </span>docker stop mycontainer</code></pre>
</div>
</div>
<div class="paragraph">
<p>The official Docker images are built using <a href="https://github.com/apache/activemq-artemis/tree/main/artemis-docker">these scripts</a> which you can also use to build your own images.
Read on for more details.</p>
</div>
</div>
</div>
<div class="sect1">
<h2 id="build-your-own-image"><a class="anchor" href="#build-your-own-image"></a><a class="link" href="#build-your-own-image">2. Build your own Image</a></h2>
<div class="sectionbody">
<div class="paragraph">
<p>In order to build an image you need an ActiveMQ Artemis binary distribution.
This can be sourced <strong>locally</strong> (in which case you need to build the project first) or <strong>remotely</strong> based on an official Apache release.</p>
</div>
<div class="sect2">
<h3 id="using-a-local-release"><a class="anchor" href="#using-a-local-release"></a><a class="link" href="#using-a-local-release">2.1. Using a Local Release</a></h3>
<div class="paragraph">
<p>If you want to use a local binary distribution then build it from the root of the ActiveMQ source tree, e.g.:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="rouge highlight nowrap"><code data-lang="console"><span class="gp">$</span><span class="w"> </span>mvn <span class="nt">-Prelease</span> package <span class="nt">-DskipTests</span></code></pre>
</div>
</div>
<div class="paragraph">
<p>Following the build the distribution files will be in your local distribution directory.
Here <code>&lt;version&gt;</code> is the version of the distribution that you built.</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="nowrap">artemis-distribution/target/apache-artemis-&lt;version&gt;-bin/apache-artemis-&lt;version&gt;</pre>
</div>
</div>
<div class="paragraph">
<p>Then switch to the <code>artemis-docker</code> directory and use the <code>prepare-docker.sh</code> script with the proper parameters to copy the Docker files into your local binary distribution, e.g.:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="rouge highlight nowrap"><code data-lang="console"><span class="gp">$</span><span class="w"> </span><span class="nb">cd </span>artemis-docker
<span class="gp">$</span><span class="w"> </span>./prepare-docker.sh <span class="nt">--from-local-dist</span> <span class="nt">--local-dist-path</span> ../artemis-distribution/target/apache-artemis-&lt;version&gt;-bin/apache-artemis-&lt;version&gt;/</code></pre>
</div>
</div>
<div class="paragraph">
<p>This will copy all the files necessary to build any of the pre-configured Docker images and provide you with additional instructions.
Follow these instructions to finish building the image you want based on one of the provided Docker files or even one of your own.</p>
</div>
</div>
<div class="sect2">
<h3 id="using-an-official-apache-release"><a class="anchor" href="#using-an-official-apache-release"></a><a class="link" href="#using-an-official-apache-release">2.2. Using an Official Apache Release</a></h3>
<div class="paragraph">
<p>If you would rather use an official Apache release in your image rather than a local release then run the following command from the <code>artemis-docker</code> directory where <code>&lt;version&gt;</code> is the release version you wish to use (e.g. <code>2.30.0</code>):</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="rouge highlight nowrap"><code data-lang="console"><span class="gp">$</span><span class="w"> </span>./prepare-docker.sh <span class="nt">--from-release</span> <span class="nt">--artemis-version</span> &lt;version&gt;</code></pre>
</div>
</div>
<div class="paragraph">
<p>This will copy all the files necessary to build any of the pre-configured Docker images and provide you with additional instructions.
Follow these instructions to finish building the image you want based on one of the provided Docker files or even one of your own.</p>
</div>
</div>
<div class="sect2">
<h3 id="customizing-the-image"><a class="anchor" href="#customizing-the-image"></a><a class="link" href="#customizing-the-image">2.3. Customizing the Image</a></h3>
<div class="sect3">
<h4 id="environment-variables"><a class="anchor" href="#environment-variables"></a><a class="link" href="#environment-variables">2.3.1. Environment Variables</a></h4>
<div class="paragraph">
<p>Environment variables determine the options configured for the <code>artemis create</code> command when running <code>docker build</code>.
The available options are:</p>
</div>
<div class="dlist">
<dl>
<dt class="hdlist1"><code>ARTEMIS_USER</code></dt>
<dd>
<p>The administrator username. The default is <code>artemis</code>.</p>
</dd>
<dt class="hdlist1"><code>ARTEMIS_PASSWORD</code></dt>
<dd>
<p>The administrator password. The default is <code>artemis</code>.</p>
</dd>
<dt class="hdlist1"><code>ANONYMOUS_LOGIN</code></dt>
<dd>
<p>Set to <code>true</code> to allow anonymous logins. The default is <code>false</code>.</p>
</dd>
<dt class="hdlist1"><code>EXTRA_ARGS</code></dt>
<dd>
<p>Additional arguments sent to the <code>artemis create</code> command. The default is <code>--http-host 0.0.0.0 --relax-jolokia</code>.
Setting this value will override the default. See the documentation on <code>artemis create</code> for available options.</p>
</dd>
</dl>
</div>
<div class="paragraph">
<p>The combination of the above environment variables results in the <code>docker-run.sh</code> script calling the following command to create the broker instance the first time the Docker container runs:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="rouge highlight nowrap"><code data-lang="console"><span class="gp">$</span><span class="o">{</span>ARTEMIS_HOME<span class="o">}</span>/bin/artemis create <span class="nt">--user</span> <span class="k">${</span><span class="nv">ARTEMIS_USER</span><span class="k">}</span> <span class="nt">--password</span> <span class="k">${</span><span class="nv">ARTEMIS_PASSWORD</span><span class="k">}</span> <span class="nt">--silent</span> <span class="k">${</span><span class="nv">LOGIN_OPTION</span><span class="k">}</span> <span class="k">${</span><span class="nv">EXTRA_ARGS</span><span class="k">}</span></code></pre>
</div>
</div>
<div class="paragraph">
<p>Note: <code>LOGIN_OPTION</code> is either <code>--allow-anonymous</code> or <code>--require-login</code> depending on the value of <code>ANONYMOUS_LOGIN</code>.</p>
</div>
<div class="paragraph">
<p>These variables can be set in the relevant Dockerfile or, for example, on the command-line, e.g.:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="rouge highlight nowrap"><code data-lang="console"><span class="gp">$</span><span class="w"> </span>docker run <span class="nt">-e</span> <span class="nv">ARTEMIS_USER</span><span class="o">=</span>myUser <span class="nt">-e</span> <span class="nv">ARTEMIS_PASSWORD</span><span class="o">=</span>myPass <span class="nt">--name</span> mycontainer <span class="nt">-it</span> <span class="nt">-p</span> 61616:61616 <span class="nt">-p</span> 8161:8161 apache/activemq-artemis:latest-alpine</code></pre>
</div>
</div>
</div>
<div class="sect3">
<h4 id="mapping-point"><a class="anchor" href="#mapping-point"></a><a class="link" href="#mapping-point">2.3.2. Mapping point</a></h4>
<div class="paragraph">
<p>The image will use the directory <code>/var/lib/artemis-instance</code> to hold the configuration and the data of the running broker.
You can map this to a folder on the host for when you want the configuration and data persisted <strong>outside</strong> of a container, e.g.:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="rouge highlight nowrap"><code data-lang="console"><span class="gp">docker run -it -p 61616:61616 -p 8161:8161 -v &lt;broker folder on host&gt;</span>:/var/lib/artemis-instance apache/activemq-artemis:latest-alpine</code></pre>
</div>
</div>
<div class="paragraph">
<p>In this case the value <code>&lt;broker folder on host&gt;</code> is a directory where the broker instance is supposed to
be saved and reused on each run.</p>
</div>
</div>
<div class="sect3">
<h4 id="overriding-files-in-etc-folder"><a class="anchor" href="#overriding-files-in-etc-folder"></a><a class="link" href="#overriding-files-in-etc-folder">2.3.3. Overriding files in <code>etc</code> folder</a></h4>
<div class="paragraph">
<p>You can use customized configuration for the ActiveMQ Artemis instance by replacing the files residing in the <code>etc</code> folder with the custom ones, e.g. <code>broker.xml</code> or <code>artemis.profile</code>.
Put the replacement files inside a folder and map it as a volume to:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="nowrap">/var/lib/artemis-instance/etc-override</pre>
</div>
</div>
<div class="paragraph">
<p>The contents of <code>etc-override</code> folder will be copied over to <code>etc</code> folder after the instance creation so that the broker will always start with user-supplied configuration.</p>
</div>
<div class="paragraph">
<p>It you are mapping the whole <code>var/lib/artemis-instance</code> to an outside folder for persistence then you can place an <code>etc-override</code> folder inside the mapped one.
Its contents will again be copied over <code>etc</code> folder after creating the instance.</p>
</div>
</div>
</div>
</div>
</div>
</div>
</body>
</html>