Modified: sites/solr/guide/solr/latest/deployment-guide/docker-faq.html
URL: 
http://svn.apache.org/viewvc/sites/solr/guide/solr/latest/deployment-guide/docker-faq.html?rev=1085656&r1=1085655&r2=1085656&view=diff
==============================================================================
--- sites/solr/guide/solr/latest/deployment-guide/docker-faq.html (original)
+++ sites/solr/guide/solr/latest/deployment-guide/docker-faq.html Thu Mar  7 
15:24:48 2024
@@ -1113,32 +1113,9 @@
 <h2 id="how-do-i-persist-solr-data-and-config"><a class="anchor" 
href="#how-do-i-persist-solr-data-and-config"></a>How do I persist Solr data 
and config?</h2>
 <div class="sectionbody">
 <div class="paragraph">
-<p>Your data is persisted already, in your container&#8217;s filesystem.
-If you <code>docker run</code>, add data to Solr, then <code>docker 
stop</code> and later <code>docker start</code>, then your data is still there.
-The same is true for changes to configuration files.</p>
-</div>
-<div class="paragraph">
-<p>Equally, if you <code>docker commit</code> your container, you can later 
create a new
-container from that image, and that will have your data in it.</p>
-</div>
-<div class="paragraph">
-<p>For some use-cases it is convenient to provide a modified 
<code>solr.in.sh</code> file to Solr.
-For example to point Solr to a ZooKeeper host:</p>
-</div>
-<div class="listingblock">
-<div class="content">
-<pre class="highlightjs highlight"><code class="language-bash hljs" 
data-lang="bash">docker create --name my_solr -P solr
-docker cp my_solr:/opt/solr/bin/solr.in.sh .
-sed -i -e 's/#ZK_HOST=.*/ZK_HOST=cylon.lan:2181/' solr.in.sh
-docker cp solr.in.sh my_solr:/opt/solr/bin/solr.in.sh
-docker start my_solr
-# With a browser go to http://cylon.lan:32873/solr/#/ and confirm 
"-DzkHost=cylon.lan:2181" in the JVM Args section.</code></pre>
-</div>
-</div>
-<div class="paragraph">
-<p>But usually when people ask this question, what they are after is a way
-to store Solr data and config in a separate <a 
href="https://docs.docker.com/userguide/dockervolumes/";>Docker Volume</a>.
-That is explained in the next two questions.</p>
+<p>Solr&#8217;s Docker image is pre-configured with container path 
<code>/var/solr/</code> as a <a 
href="https://docs.docker.com/storage/volumes/";>volume</a>.
+What this means is that all index data, log files and other variable data will 
be
+persisted on the Docker host, even if you remove the container instance.</p>
 </div>
 </div>
 </div>
@@ -1146,106 +1123,18 @@ That is explained in the next two questi
 <h2 id="how-can-i-mount-a-host-directory-as-a-data-volume"><a class="anchor" 
href="#how-can-i-mount-a-host-directory-as-a-data-volume"></a>How can I mount a 
host directory as a data volume?</h2>
 <div class="sectionbody">
 <div class="paragraph">
-<p>This is useful if you want to inspect or modify the data in the Docker host
-when the container is not running, and later easily run new containers against 
that data.
-This is indeed possible, but there are a few gotchas.</p>
-</div>
-<div class="paragraph">
-<p>Solr stores its core data in the <code>server/solr</code> directory, in 
sub-directories for each core.
-The <code>server/solr</code> directory also contains configuration files that 
are part of the Solr distribution.
-Now, if we mounted volumes for each core individually, then that would 
interfere with Solr trying to create those directories.
-If instead we make the whole directory a volume, then we need to provide those 
configuration files in our volume, which we can do by copying them from a 
temporary container.
-For example:</p>
+<p>By default Solr&#8217;s volume is persisted in Docker&#8217;s default 
storage location on the host.
+On Linux systems this is <code>/var/lib/docker/volumes</code>. This is the 
recommended way to
+store Solr&#8217;s data. You have flexibility to use a bind mount host folder 
as well:</p>
 </div>
 <div class="listingblock">
 <div class="content">
-<pre class="highlightjs highlight"><code class="language-bash hljs" 
data-lang="bash"># create a directory to store the server/solr directory
-mkdir /home/docker-volumes/mysolr1
-
-# make sure its host owner matches the container's solr user
-sudo chown 8983:8983 /home/docker-volumes/mysolr1
-
-# copy the solr directory from a temporary container to the volume
-docker run -it --rm -v /home/docker-volumes/mysolr1:/target solr cp -r 
server/solr /target/
-
-# pass the solr directory to a new container running solr
-SOLR_CONTAINER=$(docker run -d -P -v 
/home/docker-volumes/mysolr1/solr:/opt/solr/server/solr solr)
-
-# create a new core
-docker exec -it --user=solr $SOLR_CONTAINER solr create_core -c gettingstarted
-
-# check the volume on the host:
-ls /home/docker-volumes/mysolr1/solr/
-# configsets  gettingstarted  README.txt  solr.xml  zoo.cfg</code></pre>
-</div>
-</div>
-<div class="paragraph">
-<p>Note that if you add or modify files in that directory from the host, you 
must <code>chown 8983:8983</code> them.</p>
-</div>
-</div>
-</div>
-<div class="sect1">
-<h2 id="how-can-i-use-a-data-volume-container"><a class="anchor" 
href="#how-can-i-use-a-data-volume-container"></a>How can I use a Data Volume 
Container?</h2>
-<div class="sectionbody">
-<div class="paragraph">
-<p>You can avoid the concerns about UID mismatches above, by using data 
volumes only from containers.
-You can create a container with a volume, then point future containers at that 
same volume.
-This can be handy if you want to modify the solr image, for example if you 
want to add a program.
-By separating the data and the code, you can change the code and re-use the 
data.</p>
-</div>
-<div class="paragraph">
-<p>But there are pitfalls:</p>
+<pre class="highlightjs highlight"><code class="language-bash hljs" 
data-lang="bash">docker run --rm -p 8983:8983 -v $(pwd)/myData:/var/solr/ 
solr:9-slim</code></pre>
 </div>
-<div class="ulist">
-<ul>
-<li>
-<p>if you remove the container that owns the volume, then you lose your data.
-Docker does not even warn you that a running container is dependent on it.</p>
-</li>
-<li>
-<p>if you point multiple solr containers at the same volume, you will have 
multiple instances
-write to the same files, which will undoubtedly lead to corruption</p>
-</li>
-<li>
-<p>if you do want to remove that volume, you must do <code>docker rm -v 
containername</code>;
-if you forget the <code>-v</code> there will be a dangling volume which you 
can not easily clean up.</p>
-</li>
-</ul>
 </div>
 <div class="paragraph">
-<p>Here is an example:</p>
-</div>
-<div class="listingblock">
-<div class="content">
-<pre class="highlightjs highlight"><code class="language-bash hljs" 
data-lang="bash"># create a container with a volume on the path that solr uses 
to store data.
-docker create -v /opt/solr/server/solr --name mysolr1data solr /bin/true
-
-# pass the volume to a new container running solr
-SOLR_CONTAINER=$(docker run -d -P --volumes-from=mysolr1data solr)
-
-# create a new core
-docker exec -it --user=solr $SOLR_CONTAINER solr create_core -c gettingstarted
-
-# make a change to the config, using the config API
-docker exec -it --user=solr $SOLR_CONTAINER curl 
http://localhost:8983/solr/gettingstarted/config -H 
'Content-type:application/json' -d '{
-    "set-property" : {"query.filterCache.autowarmCount":1000},
-    "unset-property" :"query.filterCache.size"}'
-
-# verify the change took effect
-docker exec -it --user=solr $SOLR_CONTAINER curl 
http://localhost:8983/solr/gettingstarted/config/overlay?omitHeader=true
-
-# stop the solr container
-docker exec -it --user=solr $SOLR_CONTAINER bash -c 'cd server; java 
-DSTOP.PORT=7983 -DSTOP.KEY=solrrocks -jar start.jar --stop'
-
-# create a new container
-SOLR_CONTAINER=$(docker run -d -P --volumes-from=mysolr1data solr)
-
-# check our core is still there:
-docker exec -it --user=solr $SOLR_CONTAINER ls server/solr/gettingstarted
-
-# check the config modification is still there:
-docker exec -it --user=solr $SOLR_CONTAINER curl 
http://localhost:8983/solr/gettingstarted/config/overlay?omitHeader=true</code></pre>
-</div>
+<p>But this is both dependent on the host operating system and may run into 
different kind
+of file system permission issues.</p>
 </div>
 </div>
 </div>
@@ -1253,41 +1142,15 @@ docker exec -it --user=solr $SOLR_CONTAI
 <h2 id="can-i-use-volumes-with-solr_home"><a class="anchor" 
href="#can-i-use-volumes-with-solr_home"></a>Can I use volumes with 
SOLR_HOME?</h2>
 <div class="sectionbody">
 <div class="paragraph">
-<p>Solr supports a SOLR_HOME environment variable to point to a non-standard 
location of the Solr home directory.
-You can use this in Solr docker, in combination with volumes:</p>
+<p>While you could re-define <code>SOLR_HOME</code> inside the container, we 
instead recommend you
+to use the existing <code>SOLR_HOME</code> defined at <code>/var/solr/</code>, 
see above. You can give the
+volume a meaningful name instead of the auto generated hash, example name 
<code>solrData</code>:</p>
 </div>
 <div class="listingblock">
 <div class="content">
-<pre class="highlightjs highlight"><code class="language-bash hljs" 
data-lang="bash">docker run -it -v $PWD/mysolrhome:/mysolrhome -e 
SOLR_HOME=/mysolrhome solr</code></pre>
+<pre class="highlightjs highlight"><code class="language-bash hljs" 
data-lang="bash">docker run --rm -p 8983:8983 -v solrData:/mysolrhome 
solr:9-slim</code></pre>
 </div>
 </div>
-<div class="paragraph">
-<p>This does need a pre-configured directory at that location.</p>
-</div>
-<div class="paragraph">
-<p>To make this easier, Solr docker supports a INIT_SOLR_HOME setting, which 
copies the contents
-from the default directory in the image to the SOLR_HOME (if it is empty).</p>
-</div>
-<div class="listingblock">
-<div class="content">
-<pre class="highlightjs highlight"><code class="language-bash hljs" 
data-lang="bash">mkdir mysolrhome
-sudo chown 8983:8983 mysolrhome
-docker run -it -v $PWD/mysolrhome:/mysolrhome -e SOLR_HOME=/mysolrhome -e 
INIT_SOLR_HOME=yes solr</code></pre>
-</div>
-</div>
-<div class="admonitionblock note">
-<table>
-<tr>
-<td class="icon">
-<i class="fa icon-note" title="Note"></i>
-</td>
-<td class="content">
-If SOLR_HOME is set, the "solr-precreate" command will put the created core in 
the SOLR_HOME directory
-rather than the "mycores" directory.
-</td>
-</tr>
-</table>
-</div>
 </div>
 </div>
 <div class="sect1">
@@ -1334,56 +1197,6 @@ See the <a href="docker-networking.html"
 </div>
 </div>
 <div class="sect1">
-<h2 id="can-i-run-zookeeper-and-solr-with-docker-links"><a class="anchor" 
href="#can-i-run-zookeeper-and-solr-with-docker-links"></a>Can I run ZooKeeper 
and Solr with Docker Links?</h2>
-<div class="sectionbody">
-<div class="paragraph">
-<p>Docker&#8217;s <a 
href="https://docs.docker.com/engine/userguide/networking/default_network/dockerlinks/";>Legacy
 container links</a> provide a way to
-pass connection configuration between containers.
-It only works on a single machine, on the default bridge.
-It provides no facilities for static IPs.
-Note: this feature is expected to be deprecated and removed in a future 
release.
-So really, see the "Can I run ZooKeeper and Solr clusters under Docker?" 
option above instead.</p>
-</div>
-<div class="paragraph">
-<p>But for some use-cases, such as quick demos or one-shot automated testing, 
it can be convenient.</p>
-</div>
-<div class="paragraph">
-<p>Run ZooKeeper, and define a name so we can link to it:</p>
-</div>
-<div class="listingblock">
-<div class="content">
-<pre class="highlightjs highlight"><code class="language-bash hljs" 
data-lang="bash">docker run --name zookeeper -d -p 2181:2181 -p 2888:2888 -p 
3888:3888 jplock/zookeeper</code></pre>
-</div>
-</div>
-<div class="paragraph">
-<p>Run two Solr nodes, linked to the zookeeper container:</p>
-</div>
-<div class="listingblock">
-<div class="content">
-<pre class="highlightjs highlight"><code class="language-bash hljs" 
data-lang="bash">docker run --name solr1 --link zookeeper:ZK -d -p 8983:8983 \
-      solr \
-      bash -c 'solr start -f -z $ZK_PORT_2181_TCP_ADDR:$ZK_PORT_2181_TCP_PORT'
-
-docker run --name solr2 --link zookeeper:ZK -d -p 8984:8983 \
-      solr \
-      bash -c 'solr start -f -z 
$ZK_PORT_2181_TCP_ADDR:$ZK_PORT_2181_TCP_PORT'</code></pre>
-</div>
-</div>
-<div class="paragraph">
-<p>Create a collection:</p>
-</div>
-<div class="listingblock">
-<div class="content">
-<pre class="highlightjs highlight"><code class="language-bash hljs" 
data-lang="bash">docker exec -i -t solr1 solr create_collection \
-        -c gettingstarted -shards 2 -p 8983</code></pre>
-</div>
-</div>
-<div class="paragraph">
-<p>Then go to <code>http://localhost:8983/solr/#/~cloud</code> (adjust the 
hostname for your docker host) to see the two shards and Solr nodes.</p>
-</div>
-</div>
-</div>
-<div class="sect1">
 <h2 id="how-can-i-run-zookeeper-and-solr-with-docker-compose"><a 
class="anchor" 
href="#how-can-i-run-zookeeper-and-solr-with-docker-compose"></a>How can I run 
ZooKeeper and Solr with Docker Compose?</h2>
 <div class="sectionbody">
 <div class="paragraph">
@@ -1422,7 +1235,7 @@ set by the <code>GC_TUNE</code> environm
 <div class="sectionbody">
 <div class="paragraph">
 <p>The different invocations of the Solr docker image can look confusing, 
because the name of the image is "solr" and the Solr command is also "solr", 
and the image interprets various arguments in special ways.
-I&#8217;ll illustrate the various invocations:</p>
+Let&#8217;s illustrate the various invocations:</p>
 </div>
 <div class="paragraph">
 <p>To run an arbitrary command in the image:</p>


Reply via email to