Docker Compose容器立即退出

时间:2018-09-26 14:53:24

标签: python docker docker-compose

过去两天我一直在与Docker进行战斗,所以我真的希望有人能帮助我。我想要的是:一个运行Kafka实例的Docker,另一个运行Python检索器脚本的Docker。我希望有一个撰写文件,它将构建所有三个图像(Kafka,Zookeeper和Python)并立即执行我的Python文件。我的问题是当我进行docker-compose时,Kafka和Zookeeper容器正在工作,但Python容器立即存在。有人可以给我一种让Python容器保持运行状态的方法,以便让我进入bash吗?

命令://snippet to explain scala parametric polymorphism object MethodParametricPolymorphism { //parametric polymorphism is similar/same as of java generics def countOranges(oranges : List[Orange]) = oranges.size; def countApples(apples : List[Apple]) = apples.size //if algo is same then paramatric polymorphism can be used def count[A](items : List[A]) = items.size val oranges : List[Orange] = List( new Orange(1.1)) val apples : List[Apple] = List( new Apple(2.1), new Apple(2.2)) countOranges(oranges); countApples(apples); //using polymorphic typed method count(oranges); count(apples); case class Orange ( weight: Double) case class Apple ( weight: Double) }

docker-compose-swarm.yml文件:

root
  config
    file.conf
  src
    main
      <main packages>
    test
      <test packages>

DockerfilePython:

docker-compose down && docker-compose -f docker-compose-swarm.yml up -d

docker ps -a:

version: '3.2'
services:
  zookeeper:
    image: wurstmeister/zookeeper
    ports:
      - "2181:2181"
  kafka:
    image: wurstmeister/kafka:latest
    ports:
      - target: 9094
        published: 9094
        protocol: tcp
        mode: host
    environment:
      HOSTNAME_COMMAND: "docker info | grep ^Name: | cut -d' ' -f 2"
      KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
      KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: INSIDE:PLAINTEXT,OUTSIDE:PLAINTEXT
      KAFKA_ADVERTISED_LISTENERS: INSIDE://:9092,OUTSIDE://_{HOSTNAME_COMMAND}:9094
      KAFKA_LISTENERS: INSIDE://:9092,OUTSIDE://:9094
      KAFKA_INTER_BROKER_LISTENER_NAME: INSIDE
      KAFKA_CREATE_TOPICS: "rontgen_images"
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
  python:
    build:
      context: .
      dockerfile: DockerfilePython

0 个答案:

没有答案