为什么docker swarm中没有运行的kafka端口?

时间:2019-03-07 14:42:50

标签: docker apache-kafka grafana prometheus

我从this github项目修改了docker-stack.ymll的配置:

version: '3.1'

volumes:
    prometheus_data: {}
    grafana_data: {}

networks:
  monitor-net:

services:

  zookeeper:
    image: wurstmeister/zookeeper
    ports:
      - 2181:2181
    networks:
      - monitor-net
    restart: always
  kafka:
    image: wurstmeister/kafka
    ports:
      - 9092:9092
    environment:
      HOSTNAME_COMMAND: curl http://checkip.amazonaws.com/
      KAFKA_ADVERTISED_LISTENERS: INSIDE://:9092,OUTSIDE://_{HOSTNAME_COMMAND}:9094
      KAFKA_LISTENERS: INSIDE://:9092,OUTSIDE://:9094
      KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: INSIDE:PLAINTEXT,OUTSIDE:PLAINTEXT
      KAFKA_INTER_BROKER_LISTENER_NAME: INSIDE
      KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
      KAFKA_BROKER_ID: 1
    depends_on:
      - zookeeper
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
    deploy:
      mode: global
    networks:
      - monitor-net
    restart: always

  prometheus:
    image: prom/prometheus
    volumes:
      - ./prometheus/:/etc/prometheus/
      - prometheus_data:/prometheus
    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
    depends_on:
      - cadvisor
    networks:
      - monitor-net
    restart: always
    deploy:
      placement:
        constraints:
          - node.role==manager

  node-exporter:
    image: prom/node-exporter
    volumes:
      - /proc:/host/proc:ro
      - /sys:/host/sys:ro
      - /:/rootfs:ro
    command:
      - '--path.procfs=/host/proc'
      - '--path.sysfs=/host/sys'
      - --collector.filesystem.ignored-mount-points
      - "^/(sys|proc|dev|host|etc|rootfs/var/lib/docker/containers|rootfs/var/lib/docker/overlay2|rootfs/run/docker/netns|rootfs/var/lib/docker/aufs)($$|/)"
    ports:
      - 9100:9100
    networks:
      - monitor-net
    restart: always
    deploy:
      mode: global

  alertmanager:
    image: prom/alertmanager
    ports:
      - 9093:9093
    volumes:
      - "./alertmanager/:/etc/alertmanager/"
    networks:
      - monitor-net
    restart: always
    command:
      - '--config.file=/etc/alertmanager/config.yml'
      - '--storage.path=/alertmanager'
    deploy:
      placement:
        constraints:
           - node.role==manager

  cadvisor:
    image: google/cadvisor
    volumes:
      - /:/rootfs:ro
      - /var/run:/var/run:rw
      - /sys:/sys:ro
      - /var/lib/docker/:/var/lib/docker:ro
    ports:
      - 8080:8080
    networks:
      - monitor-net
    restart: always
    deploy:
      mode: global

  grafana:
    image: grafana/grafana
    depends_on:
      - prometheus
    ports:
      - 3000:3000
    volumes:
      - grafana_data:/var/lib/grafana
      - ./grafana/provisioning/:/etc/grafana/provisioning/
    env_file:
      - ./grafana/config.monitoring
    networks:
      - monitor-net
    restart: always

我尝试通过以下命令一起运行PrometheusGrafanaKafkaZookeep

docker stack deploy -c docker-stack.yml prom

一切正常,但是当我执行docker ps时,kafka容器没有端口:

enter image description here

所以我无法从kafka发送或接收消息。

如何使kafka端口可用?

0 个答案:

没有答案