I would like to execute a command inside the solr docker image to export metrics.
https://lucene.apache.org/solr/guide/7_3/monitoring-solr-with-prometheus-and-grafana.html
I tried with this :
command:
- solr-demo
- sh ./bin/solr-exporter -p 9854 -b http://localhost:8983/solr
Here is the complete docker-compose
version: '3.7'
volumes:
solr_data: {}
services:
solr:
image: solr:8
ports:
- "8983:8983"
volumes:
- solr_data:/var/solr
command:
- solr-demo
I don't have any errors but the command to launch the exporter is not executed.
The Prometheus way to address this issue is to run the solr-exporter as a separate docker container or side-car and have it scrape the solr server.
version: '3.7'
volumes:
solr_data: {}
services:
solr:
image: solr:8
ports:
- "8983:8983"
volumes:
- solr_data:/var/solr
command:
- solr-demo
solr-exporter:
image: solr:8
ports:
- "9854:9854"
entrypoint:
- "/opt/solr-8.2.0/contrib/prometheus-exporter/bin/solr-exporter"
- "-p"
- "9854"
- "-b"
- "http://solr:8983/solr"
- "-f"
- "/opt/solr-8.2.0/contrib/prometheus-exporter/conf/solr-exporter-config.xml"
- "-n"
- "8"
Using "http://solr:8983/solr" as the target for the exporter makes it scrape the container named solr.
The above exporter commandline was taken verbatim from the docs here, you might want to adjust it depending on your needs.
Related
I have small docker-compose
version: '3.8'
services:
solr:
image: solr:8.6.2
container_name: solr
environment:
SOLR_JAVA_HOME: /usr/local/openjdk-11
SOLR_JAVA_MEM: "-Xms1024m -Xmx8192m"
ports:
- "8983:8983"
entrypoint:
- bash
- "-c"
- "precreate-core document; exec solr -f"
command: "cp ./solr/db-data-config.xml /var/solr/data/document/conf/db-data-config.xml"
First I create core - document
Then I want replace default confgiuration
db-data-config
managed-schema
solrconfig
In this path - /var/solr/data/document/conf
What is the best way to do this?
I am trying to run the following docker-compose file:
version: "3"
services:
db:
image: postgres
container_name: pgsql
environment:
- foo=foo
- bar=bar
volumes:
- ./sql/:/opt/sql
command: bash /opt/sql/create-db.sql
# command: ps -aux
web:
image: benit/debian-web
container_name: web
depends_on:
- db
ports:
- 80:80
volumes:
- ./html:/var/www/html
I am encountering an error with the line:
command: bash /opt/sql/create-db.sql
It is because pgsql service is not started. It can be monitored with command: ps -aux
How can I run my script once pgsql service is started ?
You can use a volume to provide an initialization sql script:
version: "3"
services:
db:
image: postgres
container_name: pgsql
environment:
- foo=foo
- bar=bar
volumes:
- ./sql/:/opt/sql
- ./init.sql:/docker-entrypoint-initdb.d/init.sql
web:
image: benit/debian-web
container_name: web
depends_on:
- db
ports:
- 80:80
volumes:
- ./html:/var/www/html
This will work because original Posgresql dockerfile contains a script (that runs after Posrgres has been started) which will execute any *.sql files from /docker-entrypoint-initdb.d/ folder.
By mounting your local volume in that place, your sql files will be run at the right time.
It's actually mentioned in documentation for that image: https://hub.docker.com/_/postgres under the How to extend this image section.
I have compose file as follows;
redis:
image: redis
ports:
- "6379:6379"
php:
build: .
image: php:fpm
volumes:
- ./code:/var/www/html
links:
- redis:redis
networks:
- code-network
I'm entering into php container with the following command.
docker exec -it php_id /bin/bash
but I can't run "redis-cli" command in this container. What do I need to do to run it.
I added "links" parameter to compose file but it didn't.
You are putting the php-fpm container in a network of its own. Here is a fixed compose file:
version: "3"
services:
redis:
image: redis
ports:
- "6379:6379"
php:
build: .
image: php:fpm
volumes:
- ./code:/var/www/html
networks:
- code-network
- default
networks:
code-network:
See this for more info on compose networking.
About the redis-cli issue: You'd need to add the appropriate repository on the php-fpm container and then install it. As you are using the php:fpm image, you propably want to use redis with some php-application, therefore you don't need debians redis-cli package, but rather the php-extension.
See this post for more info.
I'm trying to run a script after Cassandra starts that will create the keyspace.
Here's my docker compose:
version: '3.6'
services:
cassandra:
container_name: cassandra
image: bitnami/cassandra:3.11.2
volumes:
- ./cassandra_data:/bitnami
- ./scripts/cassandra_init.sh:/cassandra_init.sh
environment:
- CASSANDRA_USER=${CASSANDRA_USERNAME}
- CASSANDRA_PASSWORD=${CASSANDRA_PASSWORD}
- CASSANDRA_CLUSTER_NAME=Testing
- CASSANDRA_PASSWORD_SEEDER=yes
entrypoint: ["/app-entrypoint.sh"]
command: ["nami","start","--foreground","cassandra","/cassandra_init.sh"]
volumes:
cassandra_data:
["nami","start","--foreground","cassandra"] starts Cassandra. If I start the container without adding my script, it works just fine.
However if I start the container including my script, I get this error after the container starts:
nami ERROR Unknown command '/cassandra_init.sh'
How can I achieve this?
I figured it out.
In docker.compose I had to call the script init.sh and call it:
version: '3.6'
services:
cassandra:
container_name: cassandra
image: bitnami/cassandra:3.11.2
volumes:
- ./cassandra_data:/bitnami
- ./scripts/cassandra_init.sh:/init.sh
environment:
- CASSANDRA_USER=${CASSANDRA_USERNAME}
- CASSANDRA_PASSWORD=${CASSANDRA_PASSWORD}
- CASSANDRA_CLUSTER_NAME=Testing
- CASSANDRA_PASSWORD_SEEDER=yes
entrypoint: ["/app-entrypoint.sh"]
command: ["/init.sh"]
volumes:
cassandra_data:
and the script should look like this:
#!/bin/bash
nami start cassandra
echo "script stuff here to run after cassandra starts"
I want to use excel file and some folders with my container .
I am using volumes but , dont know what the problem is with my compose .
seleniumhub:
image: selenium/hub
ports:
- "4444:4444"
firefoxnode:
image: selenium/node-firefox-debug
ports:
- "5901:5900"
links:
- "seleniumhub:hub"
shm_size: '2gb'
environment:
- "NODE_MAX_SESSION=2"
- "NODE_MAX_INSTANCES=2"
chromenode2:
image: selenium/node-chrome-debug
ports:
- "5902:5900"
links:
- "seleniumhub:hub"
shm_size: '2gb'
environment:
- "NODE_MAX_SESSION=2"
- "NODE_MAX_INSTANCES=2"
test:
image: raveena1/dilsel
ports:
- 4579
links:
- "seleniumhub:hub"
container_name: mywebcontainer
**volumes:
- /$$(pwd)/Newfolder/Config/framework-config.properties:/var/lib/docker/**
I want to use the above property file in my container , how can i achieve this ?
I don't think docker-compose can interpret bash command inside a compose file. However, what you can do is use environment variable. In your case, you might want to use $PWD.
[...]
volumes:
- $PWD/Newfolder/Config/framework-config.properties:/var/lib/docker/
[...]
This will interpret the environment variable $PWD (which resolves to your current working directy) and mount this to /var/lib/docker.
Below is an example of using environment variable in docker-compose :
docker-compose.yml:
test:
image: debian:stretch-slim
ports:
- 4579
container_name: mywebcontainer
volumes:
- $PWD/:/current_directory_of_host
entrypoint: "ls -l /current_directory_of_host"
Start this container with docker-compose up. You should see a list of file that is in your current working directory.
You can also use custom environment variable : CUSTOM_ENV=$(pwd) docker-compose up. This will forward CUSTOM_ENV to docker-compose which can be used in your docker-compose.yml.