Running solr instance inside docker

I am trying to write a shell script to run solr inside a docker container. I wrote the following script but it doesn't work. But when I give the same command step by step in terminal, it works great.

#!/bin/bash
#pull solr image
docker pull makuk66/docker-solr

#run solr on a single server
SOLR_CONTAINER=$(docker run -d -p 8983:8983 -t makuk66/docker-solr)

#create solr core
docker exec -it --user=solr $SOLR_CONTAINER bin/solr create_core -c gettingstarted

#load data using bin/post from example directory in solr installation directory
docker exec -it --user=solr $SOLR_CONTAINER bin/post -c gettingstarted example/films/films.json

      

+3


source to share


1 answer


I believe the docker solr creator does not use volumes and therefore it makes persistence / configuration more difficult. The error you get is the error you get when solr is not working.

The create_core command just sends to solr on localhost.

Different / better way is to build the kernel as part of the build. Build a Dockerfile and extend it.



My Dockerfile that builds the kernel:

FROM makuk66/docker-solr
WORKDIR /opt/solr/server/solr/
ADD . /opt/solr/server/solr/
USER root
RUN chown -R solr /opt/solr/server/solr
USER solr

      

What ADDES. adds a directory (my core) that contains empty core.properties and another director (conf) that contains schema.xml and solrconfig.xml

0


source







All Articles