I'm not getting any logging output from the RestApi which is suppose to output in Kibana. All I get is this from Kibana: No results found :(
Containers are running fine in docker with RestApi, Elasticsearch and Kibana. So I do suspect there is something in docker-compose.yml that is missing and I can't seem to figure that out. Been looking for a long time with no luck. Hopefully you can see where I have gone wrong.
Still new to programming and eager to learn. Appreciate your help.
This is how the yml file looks like in .net core:
version: '3.1'
services:
elasticsearch:
image: docker.elastic.co/elasticsearch/elasticsearch:6.2.4
container_name: elasticsearch
ports:
- "9200:9200"
volumes:
- elasticsearch-data:/usr/share/elasticsearch/data
kibana:
image: docker.elastic.co/kibana/kibana:6.2.4
container_name: kibana
ports:
- "5601:5601"
environment:
- ELASTICSEARCH_URL=http://elasticsearch:9200
RestApi:
build:
context: C:\foo\RestApi
dockerfile: Dockerfile
image: docker.restapi
container_name: RestApi
ports:
- "9000:80"
environment:
- ELASTICSEARCH_URL=http://elasticsearch:9200
volumes:
elasticsearch-data
I suggest to add the links tag.
Here a snippet of my configuration
elasticsearch:
image: elasticsearch:5.6.8
expose:
- 9200
ports:
- "9200:9200"
kibana:
image: kibana:6.2.3
links:
- "elasticsearch"
ports:
- "5601:5601"
Hope this helps.
Related
Can someone help me setting up clair with a docker image which is relatively same as
git#github.com:Charlie-belmer/Docker-security-example.git
version: '2.1'
services:
postgres:
image: postgres:12
restart: unless-stopped
volumes:
- ./docker-utils/postgres-data/:/var/lib/postgresql/data:rw
environment:
- POSTGRES_PASSWORD=ChangeMe
- POSTGRES_USER=clair
- POSTGRES_DB=clair
clair:
image: quay.io/coreos/clair:v4.3.4
restart: unless-stopped
volumes:
- ./docker-utils/clair-config/:/config/:ro
- ./docker-utils/clair-tmp/:/tmp/:rw
depends_on:
postgres:
condition: service_started
command: [-conf, /config/config.yml]
user: root
clairctl:
image: jgsqware/clairctl:latest
restart: unless-stopped
environment:
- DOCKER_API_VERSION=1.41
volumes:
- ./docker-utils/clairctl-reports/:/reports/:rw
- /var/run/docker.sock:/var/run/docker.sock:ro
depends_on:
clair:
condition: service_started
user: root
error i am getting is
2022/02/25 04:20:33 failed to validate config: indexer mode requires a database connection string
It works perfectly with clair's 2.0.6 (https://github.com/Charlie-belmer/Docker-security-example/blob/master/clair/docker-compose.yml).
How exactly I should find out what is the problem ? Clair's github is useless since they do not provide me a single docker file for my CI/CD. Any help would be appreciated.
ERROR: Encountered errors while bringing up the project.
Docker-compose up -d --build
Docker ps
------------- Docker-compose.yml -----------------
version: "3"
services:
php:
build:
context: ./docker/php
container_name: 'web'
env_file: ./docker/php/.env
restart: 'always'
ports:
- "80:80"
- "443:443"
links:
- mssql
volumes:
- ./:/var/www/html
- ./docker/config/php/php.ini:/usr/local/etc/php/php.ini
- ./docker/config/vhosts:/etc/apache2/sites-enabled
- ./docker/logs/apache2:/var/log/apache2
- ./docker/logs/php:/var/log/php
environment:
PHP_IDE_CONFIG: "serverName=local.dev.com"
mssql:
build: ./docker/mssql
container_name: 'mssql'
env_file: ./docker/mssql/.env
ports:
- "1433:1433"
volumes:
- ./docker/data/mssql:/var/opt/mssql
Make sure your port 80 isn't already in use.
Also, here's a thread with several possible solutions.
version: "1.0"
services:
es:
image: "elasticsearch:7.6.1"
container_name: myelasticsearch
ports:
- "9200:9200"
- "9300:9300"
environment:
- discovery.type=single-node
re:
image: redis
container_name: myredis
ports:
- "6379:6379"
rab:
image: "rabbitmq:3-management"
container_name: myrabbitmq
ports:
- "15672:15672"
- "5672:5672"
when i run docker-composer up it shows ERROR: Version "1.0" in ".\docker-compose.yml" is invalid. I am not finding why this error
There are three major versions of the docker-compose.yml file itself. You typically want the latest one
version: '3.7'
Version 1 was significant different from its successors: it put all of the service definitions at the top level, and didn't support top-level version: or services: keys. There are a number of other changes as well; if you need custom network configuration, Swarm support, or to specify the image name of a locally-built image, version 1 doesn't have any of these things.
version: "3.7"
services:
es:
image: "elasticsearch:7.6.1"
container_name: myelasticsearch
ports:
- "9200:9200"
- "9300:9300"
environment:
- discovery.type=single-node
re:
image: redis
container_name: myredis
ports:
- "6379:6379"
rabbitmq:
image: "rabbitmq:3-management"
container_name: myrabbitmq
ports:
- "15672:15672"
- "5672:5672"
I try to setup zipkin, elasticsearch, prometheus and grafana with docker-compose.yml
When I run dockers, see in the log:
dependencies_zipkin | 19/09/30 14:37:09 ERROR NetworkClient: Node [172.28.0.2:9200] failed (java.net.ConnectException: Connection refused (Connection refused)); no other nodes left - aborting...
I'm on MacOS X with docker 2.1.0.3
the content of my docker-compose.yml is this one:
version: '3.7'
services:
storage:
image: openzipkin/zipkin-elasticsearch7
container_name: elasticsearch
ports:
- "9200:9200"
environment:
- "xpack.security.enabled=false"
- "ES_JAVA_OPTS=-Xms512m -Xmx512m"
restart: unless-stopped
prometheus:
image: prom/prometheus:latest
container_name: prometheus
volumes:
- $PWD/prometheus:/etc/prometheus/
- /tmp/prometheus:/prometheus/data:rw
command:
- '--config.file=/etc/prometheus/prometheus.yml'
- '--storage.tsdb.path=/prometheus'
- '--web.console.libraries=/usr/share/prometheus/console_libraries'
- '--web.console.templates=/usr/share/prometheus/consoles'
ports:
- "9090:9090"
restart: unless-stopped
zipkin:
image: openzipkin/zipkin
container_name: zipkin
depends_on:
- dependencies
- storage
environment:
- "STORAGE_TYPE=elasticsearch"
- "ES_HOSTS=storage"
ports:
- "9411:9411"
restart: unless-stopped
grafana:
image: grafana/grafana
container_name: grafana
ports:
- "3000:3000"
restart: unless-stopped
dependencies:
image: openzipkin/zipkin-dependencies
container_name: dependencies_zipkin
depends_on:
- storage
environment:
- "STORAGE_TYPE=elasticsearch"
- "ES_HOSTS=storage"
When I connect to localhost:9200, I see that elasticsearch is working fine and on port 9411, zipkin is deployed but I have the error:
ERROR: cannot load service names: server error (Service Unavailable)(due to the network error
In the log, I have this information:
105 ^[[35mdependencies_zipkin |^[[0m 19/09/30 14:45:20 ERROR NetworkClient: Node [172.28.0.2:9200] failed (java.net.ConnectException: Connection refused (Connection refused)); no other nodes left - aborting...
and this one
^[[31mzipkin |^[[0m java.lang.IllegalStateException: couldn't connect any of [Endpoint{storage:80, ipAddr=172.28.0.2, weight=1000}]
Any idea?
UPDATE
by using mysql it is working fine, so the problem is at the level of elastic search.
I tried alsoo by using
"STORAGE_PORT_9200_TCP_ADDR=127.0.0.1"
but the issue still occurs.
UPDATE
As mention is the solution gave by Brian, I have to use:
ES_HOSTS=http://storage:9300
the key is on port, I was using the port 9200
The error disappear between zipkin and es but still occurs between es and zipkin-dependencies.
The problem lies in your ES_HOSTS variable, from the docs here:
ES_HOSTS: A comma separated list of elasticsearch base urls to connect to ex. http://host:9200.
Defaults to "http://localhost:9200".
So you will need: ES_HOSTS=http://storage:9200
Finally I have this file:
version: '3.7'
services:
storage:
image: openzipkin/zipkin-elasticsearch7
container_name: elasticsearch
ports:
- 9200:9200
zipkin:
image: openzipkin/zipkin
container_name: zipkin
environment:
- STORAGE_TYPE=elasticsearch
- "ES_HOSTS=elasticsearch:9300"
ports:
- 9411:9411
depends_on:
- storage
dependencies:
image: openzipkin/zipkin-dependencies
container_name: dependencies
entrypoint: crond -f
depends_on:
- storage
environment:
- STORAGE_TYPE=elasticsearch
- "ES_HOSTS=elasticsearch:9300"
- "ES_NODES_WAN_ONLY=true"
prometheus:
image: prom/prometheus:latest
container_name: prometheus
volumes:
- $PWD/prometheus:/etc/prometheus/
- /tmp/prometheus:/prometheus/data:rw
command:
- '--config.file=/etc/prometheus/prometheus.yml'
- '--storage.tsdb.path=/prometheus'
- '--web.console.libraries=/usr/share/prometheus/console_libraries'
- '--web.console.templates=/usr/share/prometheus/consoles'
ports:
- "9090:9090"
grafana:
image: grafana/grafana
container_name: grafana
depends_on:
- prometheus
ports:
- "3000:3000"
Main differences are the usage of
"ES_HOSTS=elasticsearch:9300"
instead of
"ES_HOSTS=storage:9300"
and in the dependencies configuration I add the entrypoint in dependencies:
entrypoint: crond -f
This one is really the key to not have the exception when I start docker-compose.
To solve this issue, I check the this project: https://github.com/openzipkin/docker-zipkin
The remaining question is: why do I need to use entrypoint: crond -f
Here is my docker-compose.yml file
version: '3'
services:
mongodb:
image: hedge-mongo:1.0
container_name: mongodb
ports:
- "27017:27017"
networks:
- appNetwork
service-A:
image: service-A:1.0
container_name: service-A
ports:
- "3030:3030"
networks:
- appNetwork
depends_on:
- mongodb
service-B:
image: service-B:1.0
container_name: service-B
ports:
- "4200:4200"
networks:
- appNetwork
service-C:
image: service-C:1.0
container_name: service-C
ports:
- "8082:8082"
networks:
- appNetwork
networks:
appNetwork:
external: true
In above file service-A and service-C are trying to connect to MongoDB
Issue:
In above file service-A and service-C are getting connected to MongoDB before MongoDB is up
so, I want to run service-A and service-C after MongoDB is up completely.
I tried adding depends-on for service-A and service-C
service-A:
image: service-A:1.0
container_name: service-A
ports:
- "3030:3030"
networks:
- appNetwork
depends_on:
- mongodb
service-C:
image: service-C:1.0
container_name: service-C
ports:
- "8082:8082"
networks:
- appNetwork
depends_on:
- mongodb
still, it did not work out sometimes it works sometimes it doesn't so it's not reliable.
I want to make sure my other services are up only after MongoDB is up.
that is a race condition, you're services is trying to start at the same time, thats why you got a result of sometimes it success and sometimes its not.. here an example on how to solve the race condition..
example 1
example 2