Suppose I have 2 yml files which I run via docker-compose up.
efk.yml:
version: '3.3'
services:
fluentd:
image: fluentd
...
volumes:
- ./fluentd/etc:/fluentd/etc
depends_on:
- elasticsearch
ports:
- "24224:24224"
- "24224:24224/udp"
elasticsearch:
image: amazon/opendistro-for-elasticsearch:1.13.3
expose:
- 9200
ports:
- "9200:9200"
environment:
- "discovery.type=single-node"
kibana:
...
logging:
driver: "fluentd"
options:
fluentd-address: localhost:24224
tag: micro.kibana
(I've omit some irrelevant part, I need just logging)
app.yml:
version: '3.3'
services:
mysql:
image: mysql
..
logging:
driver: "fluentd"
options:
fluentd-address: fluentd:24224
# fluentd-async-connect: "true"
tag: micro.db
networks:
- default
app:
...
logging:
driver: "fluentd"
options:
fluentd-address: fluentd:24224
# fluentd-async-connect: "true"
tag: micro.php-fpm
networks:
- default
networks:
default:
external:
name: efk_default
I plan to launch efk stack initially like
docker-compose -p efk -f efk.yml up -d
and then:
docker-compose -p app -f app.yml up -d
I assume that bridge network efk_default will be created and I can access it from app stack (see app.yml for details). But app stack couldn't resolve fluentd:24224 in bridge network, I get following error on command above for app:
ERROR: for app Cannot start service app: failed to initialize logging driver: dial tcp: lookup fluentd: Temporary failure in name resolution ERROR: Encountered errors while bringing up the project.
If I use smth dumb like localhost:24224 just to make it launch, via docker network inspect I can see all containers in one network. I've tried to use ip addr. in bridged network but it didn't work either.
Is it possible to have common logging service within this configuration? If yes, what I'm doing wrong?
Thanks in advance.
CodePudding user response:
Here's what I did to test it:
compose1.yml
version: '3'
services:
app1:
image: nginx
compose2.yml
version: '3'
services:
app2:
image: curlimages/curl
command: http://app1/
networks:
default:
external:
name: efk_default
Commands run:
docker-compose -p efk -f compose1.yml up -d
docker-compose -p efk -f compose2.yml up
and it outputs the Nginx welcome page.