<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/">
  <channel>
    <title>solr &amp;mdash; Arturo Linares</title>
    <link>https://arturo.linar.es/tag:solr</link>
    <description></description>
    <pubDate>Fri, 19 Jun 2026 13:16:14 +0000</pubDate>
    <item>
      <title>Setup Solr and Drupal using Docker</title>
      <link>https://arturo.linar.es/setup-solr-and-drupal-using-docker?pk_campaign=rss-feed</link>
      <description>&lt;![CDATA[#drupal #solr&#xA;&#xA;Last time I tried to create from scratch a Drupal instance that used a Solr server wasn’t as easy as I expected. Maybe command line tools for installing modules have spoiled me and I just expected that running something like drupal module:install solr would configure everything for me.&#xA;&#xA;Here is how I made it work, but please consider I’m not a Solr expert. If you know a better way to do this please let me know.&#xA;!--more--&#xA;Setup Drupal&#xA;&#xA;Let’s suppose we want to create a blog that uses a Solr for searching its contents.&#xA;&#xA;First, to create a basic Drupal install we can use a recently released project from WeKnow to quickly create a Drupal instance using Docker. Follow the README file keeping the default .env values so we can install Drupal using this command:&#xA;&#xA;    $ docker-compose exec --user=82 php drupal site:install standard --db-host=mariadb --db-name=drupal --db-user=drupal --db-pass=drupal --quiet&#xA;&#xA;Don’t forget to add the hosts entry, as mentioned in the README file, or use a proxy like hotel. The objective is to use a custom domain name that the web server can identify (if we use localhost and in the .env file we used  HOSTNAME=drupal.vm the web server won’t serve the request).&#xA;&#xA;You can verify it is working if you see a fresh Drupal install when you visit  http://drupal.develop.&#xA;&#xA;Install Solr&#xA;&#xA;Let’s install Solr now. We will need some config files found in the module to setup our Solr core, so lets download it inside the container:&#xA;&#xA;$ docker-compose exec --user=82 php composer req drupal/searchapisolr&#xA;&#xA;We will create a sample core named blog. Copy the files located at web/modules/contrib/searchapisolr/solr-conf/5.x/ to env/solr/blog/conf/ and create this file in env/solr/blog/core.properties (you will need to create the env dir):&#xA;&#xA;env/solr/blog/core.properties&#xA;    name=blog&#xA;    config=solrconfig.xml&#xA;    schema=schema.xml&#xA;    dataDir=/var/lib/solr/books&#xA;&#xA;Update docker-compose.yml to include the solr container and config its port and a way to access it using traefik (using http://solr.drupal.develop if using the defaults in .env):&#xA;&#xA;docker-compose.yml&#xA;    services:&#xA;      # ...&#xA;      solr:&#xA;        image: solr:5.5&#xA;        labels:&#xA;          &#39;traefik.backend=solr&#39;&#xA;          &#39;traefik.port=8983&#39;&#xA;          &#39;traefik.frontend.rule=Host:solr.${HOSTNAME}&#39;&#xA;        volumes:&#xA;          ./env/solr/blog:/opt/solr/server/solr/blog&#xA;          solrdata:/var/lib/solr&#xA;&#xA;    volumes:&#xA;      mysqldata:&#xA;        driver: &#34;local&#34;&#xA;      solrdata:&#xA;        driver: &#34;local&#34;&#xA;&#xA;  Don’t forget to add the solr.drupal.develop to your hosts file).&#xA;&#xA;After running docker-compose up -d (and adding to your hosts file the entry for solr.drupal.development) you will see this error in solr:&#xA;&#xA;This happened because the user and the uid has to match with the user the solr process runs as in the solr container. To fix this we have to create another container that fixes the perms where the core will write the index.&#xA;&#xA;We will use just-containers/base-alpine image, which has utilities to do this (s6).&#xA;&#xA;Add the docker file to update fix the perms and update docker-compose to use this new container:&#xA;&#xA;./dockerfiles/solrdata/Dockerfile&#xA;    FROM just-containers/base-alpine&#xA;    VOLUME [&#34;/var/lib/solr&#34;]&#xA;    ADD root /&#xA;&#xA;./dockerfiles/solrdata/root/etc/fixattrs.d&#xA;    /var/lib/solr false solr,8983 0755&#xA;&#xA;And update the docker-compose.yml to include this image:&#xA;    services:&#xA;      solr:&#xA;        image: solr:5.5&#xA;        labels:&#xA;          &#39;traefik.backend=solr&#39;&#xA;          &#39;traefik.port=8983&#39;&#xA;          &#39;traefik.frontend.rule=Host:solr.${HOSTNAME}&#39;&#xA;&#xA;        # add the volumes from the new container&#xA;        volumesfrom:&#xA;          solrdata&#xA;        # the core configs&#xA;        volumes:&#xA;          ./env/solr/blog:/opt/solr/server/solr/books&#xA;&#xA;      # added container to fix perms&#xA;      solrdata:&#xA;        build: ./dockerfiles/solrdata&#xA;        volumes:&#xA;          realsolrdata:/var/lib/solr&#xA;&#xA;    volumes:&#xA;      mysqldata:&#xA;        driver: &#34;local&#34;&#xA;      realsolrdata:&#xA;        driver: &#34;local&#34;&#xA;&#xA;Now if you run docker-compose up -d and you visit the Solr page you should see your errors fixed.&#xA;&#xA;Configure Solr&#xA;&#xA;Now that we have the server running, lets configure Drupal so we can use it as a search engine. Fortunately, most of the hard work is solved by enabling searchapisolrdefault module.&#xA;&#xA;    $ docker-compose exec --user=82 php drupal moi searchapisolr_defaults&#xA;&#xA;Go to the Search API configs (/admin/config/search/search-api) and you will see a new Solr server entry, although with errors because it is missing the server name and the core it will use.&#xA;&#xA;Click edit and set the host (ie. the solr container name, solr) and the core we created before (blog):&#xA;&#xA;Click save and you should be able to to see all green when you go back to the Search API config page. You can now start using your solar server for searching.&#xA;&#xA;  The defaults module contains a sample search page to easily get you started in /solr-search/content. It is implemented as a View.&#xA;&#xA;References&#xA;&#xA;You might find this links useful:&#xA;&#xA;Outrigger examples&#xA;Try Drupal&#xA;&#xA;Permalink: Setup Solr and Drupal using Docker&#xA;]]&gt;</description>
      <content:encoded><![CDATA[<p><a href="https://arturo.linar.es/tag:drupal" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">drupal</span></a> <a href="https://arturo.linar.es/tag:solr" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">solr</span></a></p>

<p>Last time I tried to create from scratch a Drupal instance that used a Solr server wasn’t as easy as I expected. Maybe command line tools for installing modules have spoiled me and I just expected that running something like <code>drupal module:install solr</code> would configure everything for me.</p>

<p>Here is how I made it work, but please consider I’m not a Solr expert. If you know a better way to do this please let me know.
</p>

<h2 id="setup-drupal" id="setup-drupal">Setup Drupal</h2>

<p>Let’s suppose we want to create a blog that uses a Solr for searching its contents.</p>

<p>First, to create a basic Drupal install we can use a recently released project from <a href="http://weknowinc.com" rel="nofollow">WeKnow</a> to quickly create a Drupal instance using Docker. Follow the README file keeping the default <code>.env</code> values so we can install Drupal using this command:</p>

<p>    $ docker-compose exec —user=82 php drupal site:install standard —db-host=mariadb —db-name=drupal —db-user=drupal —db-pass=drupal —quiet</p>

<p>Don’t forget to add the <code>hosts</code> entry, as mentioned in the README file, or use a proxy like <a href="https://github.com/typicode/hotel" rel="nofollow">hotel</a>. The objective is to use a custom domain name that the web server can identify (if we use localhost and in the <code>.env</code> file we used  <code>HOST_NAME=drupal.vm</code> the web server won’t serve the request).</p>

<p>You can verify it is working if you see a fresh Drupal install when you visit  <code>http://drupal.develop</code>.</p>

<h2 id="install-solr" id="install-solr">Install Solr</h2>

<p>Let’s install Solr now. We will need some config files found in the module to setup our Solr core, so lets download it inside the container:</p>

<pre><code>$ docker-compose exec --user=82 php composer req drupal/search_api_solr
</code></pre>

<p>We will create a sample core named *blog*<em>.</em> Copy the files located at <code>web/modules/contrib/search_api_solr/solr-conf/5.x/</code> to <code>env/solr/blog/conf/</code> and create this file in <code>env/solr/blog/core.properties</code> (you will need to create the <em>env</em> dir):</p>

<p><em>env/solr/blog/core.properties</em></p>

<pre><code>    name=blog
    config=solrconfig.xml
    schema=schema.xml
    dataDir=/var/lib/solr/books
</code></pre>

<p>Update <code>docker-compose.yml</code> to include the <code>solr</code> container and config its port and a way to access it using traefik (using <code>http://solr.drupal.develop</code> if using the defaults in <code>.env</code>):</p>

<p><em>docker-compose.yml</em></p>

<pre><code>    services:
      # ...
      solr:
        image: solr:5.5
        labels:
          - &#39;traefik.backend=solr&#39;
          - &#39;traefik.port=8983&#39;
          - &#39;traefik.frontend.rule=Host:solr.${HOST_NAME}&#39;
        volumes:
          - ./env/solr/blog:/opt/solr/server/solr/blog
          - solrdata:/var/lib/solr

    volumes:
      mysqldata:
        driver: &#34;local&#34;
      solrdata:
        driver: &#34;local&#34;
</code></pre>

<blockquote><p>Don’t forget to add the <code>solr.drupal.develop</code> to your hosts file).</p></blockquote>

<p>After running <code>docker-compose up -d</code> (and adding to your hosts file the entry for <code>solr.drupal.development</code>) you will see this error in solr:</p>

<p><img src="https://i.snap.as/rk3bXbc.png" alt=""/></p>

<p>This happened because the user and the uid has to match with the user the solr process runs as in the solr container. To fix this we have to create another container that fixes the perms where the core will write the index.</p>

<p>We will use <code>just-containers/base-alpine</code> image, which has utilities to do this (<a href="https://github.com/just-containers/s6-overlay" rel="nofollow">s6</a>).</p>

<p>Add the docker file to update fix the perms and update docker-compose to use this new container:</p>

<p><em>./dockerfiles/solr_data/Dockerfile</em></p>

<pre><code>    FROM just-containers/base-alpine
    VOLUME [&#34;/var/lib/solr&#34;]
    ADD root /
</code></pre>

<p><em>./dockerfiles/solr_data/root/etc/fixattrs.d</em></p>

<pre><code>    /var/lib/solr false solr,8983 0755
</code></pre>

<p>And update the <code>docker-compose.yml</code> to include this image:</p>

<pre><code>    services:
      solr:
        image: solr:5.5
        labels:
          - &#39;traefik.backend=solr&#39;
          - &#39;traefik.port=8983&#39;
          - &#39;traefik.frontend.rule=Host:solr.${HOST_NAME}&#39;

        # add the volumes from the new container
        volumes_from:
          - solr_data
        # the core configs
        volumes:
          - ./env/solr/blog:/opt/solr/server/solr/books

      # added container to fix perms
      solr_data:
        build: ./dockerfiles/solr_data
        volumes:
          - real_solr_data:/var/lib/solr

    volumes:
      mysqldata:
        driver: &#34;local&#34;
      real_solr_data:
        driver: &#34;local&#34;
</code></pre>

<p>Now if you run <code>docker-compose up -d</code> and you visit the Solr page you should see your errors fixed.</p>

<h2 id="configure-solr" id="configure-solr">Configure Solr</h2>

<p>Now that we have the server running, lets configure Drupal so we can use it as a search engine. Fortunately, most of the hard work is solved by enabling <code>search_api_solr_default</code> module.</p>

<pre><code>    $ docker-compose exec --user=82 php drupal moi search_api_solr_defaults
</code></pre>

<p>Go to the Search API configs (<code>/admin/config/search/search-api</code>) and you will see a new Solr server entry, although with errors because it is missing the server name and the core it will use.</p>

<p><img src="https://i.snap.as/atHaCF1.png" alt=""/></p>

<p>Click edit and set the host (ie. the solr container name, <em>solr</em>) and the core we created before (<em>blog</em>):</p>

<p><img src="https://i.snap.as/8YeLfr1.png" alt=""/></p>

<p>Click save and you should be able to to see all green when you go back to the Search API config page. You can now start using your solar server for searching.</p>

<blockquote><p>The defaults module contains a sample search page to easily get you started in <code>/solr-search/content</code>. It is implemented as a View.</p></blockquote>

<h2 id="references" id="references">References</h2>

<p>You might find this links useful:</p>
<ul><li><a href="https://github.com/phase2/outrigger-examples" rel="nofollow">Outrigger examples</a></li>
<li>Try Drupal</li></ul>

<p>Permalink: <a href="arturolinar.es/blog/post/setup-solr-and-drupal-using-docker" rel="nofollow">Setup Solr and Drupal using Docker</a></p>
]]></content:encoded>
      <guid>https://arturo.linar.es/setup-solr-and-drupal-using-docker</guid>
      <pubDate>Wed, 07 Mar 2018 06:20:41 +0000</pubDate>
    </item>
  </channel>
</rss>