Solr with Drupal and docker (wodby docker4drupal) using search api solr

With docker4drupal its easy to enable solr whith docker-compose, its is also easy to do that with other drupal docker bundles. But to make this work it needs some manual work as well. First you need to make sure solr runs properly, test it, see that url to it shows it runs. Then first thing you need to do is to make a new CORE for solr, you can make that manually just adding files to your solr installation or run the command that makes that. Lets do this in combination. First log in to your solr container, lets do it like this

docker-compose exec solr bash

then go to your solr installation and path where you need to put new cores, probably it will be here /opt/solr/server/solr
then lets make a NEW CORE, we do it like this

/opt/solr/bin/solr create -c test_core

with that we will get a new folder with some config. Go into that folder and delete conf directory content and then go into it. We want to copy DRUPAL specific solr config, which we can find with search_api_solr  module /modules/contrib/search_api_solr/solr-conf
We choose a corresponding version of config per our solr installation. If you have solr 7.x installed, just use config for 6.x from drupal module.
To copy all that to our container, you need to find a name of solr container and then copy content, lets do it like this.

docker cp /Users/marko/my_site/web/modules/contrib/search_api_solr/solr-conf/6.x/. container_solr:/opt/solr/server/solr/test_core/conf

we copied files and they are now in /opt/solr/server/solr/test_core/conf ready to be used.
Last step is to configure drupal with drupal ui. So we go to search api here 


and go to add server and index. We wont go into details about search api, but will just make an important note here. As we are using docker, although over browser you can reach your solr over url like this http://solr.localhost:8000/solr/#/~cores/test_core this should not be in your config in drupal ui. You should set solr host to name of your container and with internal port number, so host will probably be solr and port will be 8983. Which should in the end make 
http://solr:8983/solr/ and Solr core URI    http://solr:8983/solr/#/test_core

Also when using docker4drupal you should edit your /etc/hosts file and add line like solr.dd.local

so it will be visible and your environment can use it. So if your site is at


your solr will be at


This should be it, you should now have running solr service that can index your data. Just restart docker containers so solr service gets loaded with new config.