Reputation: 7151
I am creating my container with :
docker pull solr
docker run --name solr_demo -d -p 8983:8983 -t solr
I need to configure some solr files but the user is solr not root. I also can not install vim or any other programs because of the privileges when i connect to the container with bash.
My question is: Can i see and edit all container files in my filesystem? Is this somehow related to docker volumes? If so any example command would be very appreciated. Tried to read the documentation but it is so confusing.
Thanks
Upvotes: 1
Views: 747
Reputation: 5220
Your answer solves your problem, but I wouldn't consider it more than a workaround. This is not exactly what volumes are designed for.
Now, answering your question.
You can log in as root and do your stuff this way:
docker exec -it -u root solr_demo bash
I'd recommend another approach though. As stated in Solr Docker image documentation ('Extending the image' section), you can put any initialization scripts in /docker-entrypoint-initdb.d/
folder in container's filesystem (either by mounting a volume or extending the image and COPYing the scripts there). They will be run before Solr service is started.
Upvotes: 2
Reputation: 7151
Not exactly what i was after but it solves my problem.
# 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
Upvotes: 0