File not found when use Volume in docker-compose.yml

I want to use volume to mount kafka’s config to my localhost ,but when i check the target folder ,i find only one file,others are deleted ,there is some snapshot to describe

  1. origin folder

  2. latest folder

    only server.properties saved

  3. docker-compose.yml
    kafka1:
    image: wurstmeister/kafka
    restart: always
    hostname: kafka1
    container_name: kafka1
    ports:
    - 9092:9092
    environment:
    KAFKA_BROKER_ID: 1
    KAFKA_ADVERTISED_HOST_NAME: kafka1
    KAFKA_ADVERTISED_PORT: 9092
    KAFKA_ZOOKEEPER_CONNECT: zoo1:2181,zoo2:2181,zoo3:2181
    KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://kafka1:9092
    KAFKA_LISTENERS: PLAINTEXT://kafka1:9092
    volumes:
    - /Users/sun9/dockerKafkaService/volume/kfkluster/kafka1/logs:/kafka
    - /Users/sun9/dockerKafkaService/volume/kfkluster/kafka1/config:/opt/kafka/config
    external_links:
    - zoo1
    - zoo2
    - zoo3
    networks:
    zookeeper_kafka:
    ipv4_address: 172.19.0.14
    depends_on:
    - zoo1
    - zoo2
    - zoo3

I’m confused about this

Docker version 19.03.13, build 4484c46d9d
MacOS 10.15.6

You don’t mount the folder from the container to localhost, but the folder from localhost into the container. This means the config files have to be present on your host before you run the compose script.

thanks !!! i get this :grin: