31z4 / zookeeper-docker

Docker image packaging for Apache Zookeeper
MIT License
285 stars 245 forks source link

logs will be missing when mounting logs and conf at the same time #69

Closed icql closed 5 years ago

icql commented 5 years ago

logs will be missing when mounting logs and conf at the same time. zookeeper 3.5.5

Expected behavior

the log4j file should exist.

Actual behavior

the log4j file is missing.

Steps to reproduce the behavior

docker-compose up by the following configuration file.

System configuration

docker-compose.yml

version: '3.1'

services:
  zoo1:
    image: zookeeper:3.5.5
    restart: always
    hostname: zoo1
    container_name: zookeeper_1
    ports:
      - 2181:2181
    volumes:
      - /app/zookeeper/zoo1/data:/data
      - /app/zookeeper/zoo1/datalog:/datalog
      - /app/zookeeper/zoo1/logs:/logs
      - /app/zookeeper/zoo1/conf:/conf
    environment:
      ZOO_MY_ID: 1
      ZOO_SERVERS: server.1=zoo1:2888:3888;2181 server.2=zoo2:2888:3888;2181 server.3=zoo3:2888:3888;2181
      ZOO_LOG4J_PROP: "INFO,ROLLINGFILE"
      ZOO_ADMINSERVER_ENABLED: "false"

  zoo2:
    image: zookeeper:3.5.5
    restart: always
    hostname: zoo2
    container_name: zookeeper_2
    ports:
      - 2182:2181
    volumes:
      - /app/zookeeper/zoo2/data:/data
      - /app/zookeeper/zoo2/datalog:/datalog
      - /app/zookeeper/zoo2/logs:/logs
      - /app/zookeeper/zoo2/conf:/conf
    environment:
      ZOO_MY_ID: 2
      ZOO_SERVERS: server.1=zoo1:2888:3888;2181 server.2=zoo2:2888:3888;2181 server.3=zoo3:2888:3888;2181
      ZOO_LOG4J_PROP: "INFO,ROLLINGFILE"
      ZOO_ADMINSERVER_ENABLED: "false"

  zoo3:
    image: zookeeper:3.5.5
    restart: always
    hostname: zoo3
    container_name: zookeeper_3
    ports:
      - 2183:2181
    volumes:
      - /app/zookeeper/zoo3/data:/data
      - /app/zookeeper/zoo3/datalog:/datalog
      - /app/zookeeper/zoo3/logs:/logs
      - /app/zookeeper/zoo3/conf:/conf
    environment:
      ZOO_MY_ID: 3
      ZOO_SERVERS: server.1=zoo1:2888:3888;2181 server.2=zoo2:2888:3888;2181 server.3=zoo3:2888:3888;2181
      ZOO_LOG4J_PROP: "INFO,ROLLINGFILE"
      ZOO_ADMINSERVER_ENABLED: "false"
31z4 commented 5 years ago

As per official documentation

The ZooKeeper default log4j.properties file resides in the conf directory. Log4j requires that log4j.properties either be in the working directory (the directory from which ZooKeeper is run) or be accessible from the classpath.

Since you're mounting the whole /conf directory its default content including log4j.properties file is rewritten.

The solution here would be either putting log4j.properties to your /app/zookeeper/zooX/conf or mounting only the config file: /app/zookeeper/zooX/conf/zoo.cfg:/conf/zoo.cfg

icql commented 5 years ago

Thanks