Compose: A "graceful" service start even if the logging driver service/container is not running

Created on 21 Jun 2019  路  7Comments  路  Source: docker/compose

Hi,

When I try to start "application" containers I get errors below. The reason is because the monitoring_fluent_bit container is not running yet. However, it would be nice if there was an "graceful" start option under logging.options so if the monitoring_fluent_bit container is not running/available yet, the application services should still run. Does that make sense?

Thanks

ERROR: for app_php_1 Cannot start service app_php: failed to initialize logging driver: dial tcp 127.0.0.1:24224: connect: connection refused

ERROR: for app_php Cannot start service app_php: failed to initialize logging driver: dial tcp 127.0.0.1:24224: connect: connection refused
ERROR: Encountered errors while bringing up the project.

application compose

version: "3.4"

services:
  app_php:
    ...
    logging:
      driver: "fluentd"
      options:
        fluentd-address: "monitoring_fluent_bit"
        mode: "non-blocking"
        max-buffer-size: "2m"
  app_nginx:
    ...
  app_mysql:
    ...

monitoring compose

version: "3.4"

services:
  monitoring_fluent_bit:
    image: "fluent/fluent-bit:1.0.4"
    ...
  monitoring_es:
    ...
  monitoring_kibana:
    ...
kinfeature

Most helpful comment

I believe you're looking for the fluentd-async-connect log option.

All 7 comments

Hi @BentCoder,

Thanks for the suggestion. You may be able to use depends_on to work around this. Errors like that are unfortunately something that you'll encounter when working on eventually consistent systems.

Thanks for the answer @chris-crone . I should have explained it better though :disappointed:

If the service which is used as the logging driver is not available yet, the service should still be able to start. The reason is because, for instance, my logging drivers are external services. Is there a solution to this?

I've just noticed that I am not the only one who picked up on it.

Using Docker鈥檚 Fluentd logging driver, if the Fluentd container is not available on the container鈥檚 host, the container logging to Fluentd will fail (major con!)

So technically if the logging driver related service (internal or external) is not running for whatever reason, the dependent service/container should still be able to run.

As a simple solution, there can be a kind of fallback option if the logging driver related service is not running. e.g. If service X (php, nginx ...) depends on service Y (fluent, logstash ...) and if the service Y is not running then service X still starts while logging into std.

I am sure this is relatively easy solution just like non existent env variables are handled with empty values.

+1 -- getting error:
docker: Error response from daemon: failed to initialize logging driver: dial tcp 150.30.1.40:24224: connect: connection refused.

it is not starting a new container when logging drive container is down.

Please help-- implement the solution as mentioned by BentCoder

Ping. Anyone interested in this issue please?

I believe you're looking for the fluentd-async-connect log option.

@nitper That solves the problem. Thank you for pointing out.

Was this page helpful?
0 / 5 - 0 ratings