详细信息:我正尝试使用本文末尾附带的docker-compose.yml文件运行wurstmeister/kafka和wurstmeister/zookeeper图像。
要测试容器,我遵循了official site of kafka。它引用图像中不可用的某些脚本,例如data limbs;
input LowerLimb @@;
datalines;
0.5945611665 -0.5826515170 -1.2089586047 -0.7638814175 -1.3541648163 -0.8279052306 -0.9069854423 0.9439623714 -0.1525671573 0.4056990026
1.5466954947 0.4034370839 0.8766515519 -1.5657943810 0.1315781412 0.5884629368 0.6104427011 -0.1874296672 -0.6318866100 -1.0145154507
0.4573267066 -0.0788037696 0.0988716187 -0.1062918576 1.6032740744 0.0366051704 1.2256319114 -0.0975189376 -0.2566850316 1.6652074953
-0.2515183734 0.5004921436 -0.1593883100 0.8129010817 1.1351908320 0.8123843303 1.2870155459 -1.1128448929 0.4506147031 -0.6403088674
-1.0680294390 0.6944292489 -1.5325710123 0.5268637927 1.2873515926 -0.1441695459 -0.7166217143 1.2461334186 -0.9583531596 -0.7342533139
-0.4907715810 0.2059216422 -1.3839801362 0.7310499731 0.6130932991 1.0859079024 1.4255534497 -0.1813774454 0.6544726467 -1.0171713430
-0.5005970523 0.5884629368 -1.4752458285 -0.9195150817 -1.4752458285 0.8515222486 -0.6348874123 -1.0206723355 -0.3331377791 -1.1015990720
-0.1196299907 -0.3504059025 -0.5797983640 -0.2784242647 0.4381186749 0.4665127006 -1.8605760577 -1.5943485819 -0.4196862951 0.5247889197
1.6982671983 -0.5015070356 0.2510690218 -0.1088654424 -0.0470926244 -1.1256998568 -0.4694781522 -0.4903309954 -0.1706456902 -0.7996053224
-0.2106636370 1.1087050595 1.5393390992 0.6407710538 0.8738320036 -1.1218388138 0.5477816746 0.5999120789 0.2915917178 0.5932996471
-0.4754278117 -0.1195030573 0.3480903069 0.1629924791 -0.8543653798 0.0602221361 -0.3484280234 0.8213886228 1.0996879917 -1.0171713430
-0.2613938856 0.1435928118 -0.2410397237 2.0380301721 0.9942206208 -0.7858668669 1.0463609814 0.5651396814 -0.4366703308 -1.2232641582
-0.3770888329 -1.9197016431 1.0463609814 -1.3738499052 -1.0554234361 1.1701816705 -0.8687068897 -0.8743902197 -1.3518493892 -1.6473112739
-0.2953961077 0.5734156662 0.5065516647 1.1603237185 -0.3369092077 1.0982075159 -1.0002141384 -0.9192524613 -0.0431072738 -0.0742208903
0.8658302777 -1.1095158202 -0.8361540961 0.5871263103 -0.3311134236 0.3331929252 -0.6499008335 -1.1966097379 0.7227541366 0.1853978157
0.8074323856 -0.8096153897 -1.0220042319 1.1172583088 1.3540629514 -1.3149667205 -0.7600725098 1.1145492382 1.3270625584 1.1572834877
-1.1877623250 0.3202875975 0.8779400227 -0.4333817521 1.2656618368 -1.1416425163 -0.9014599711 0.3918324501 -0.7997140876 -0.2229835864
-0.0362833762 -0.4399531798 1.1975110853 -0.0183032379 -0.7413393186 0.8474043498 1.2789829755 0.8673767628 -0.4438902513 1.0776590402
0.1910287517 1.1313548102 0.8659515949 -0.9444619985 -0.9926366647 0.6447604307 0.8370824694 -0.8917575544 1.5862615371 0.8437626048
0.2362696149 -1.1429415083 -1.2621422188 -0.7364910931 0.3618265073 0.1708182871 -0.3114446248 0.0011119450 -1.0323790009 0.5951509779
1.6392758858 0.9646250229 -0.9076823320 -0.1409210592 -0.8529359998
;;;;
run;
proc sort data=limbs;
by lowerLimb;
run;
proc rank data=limbs out=bin groups=3;
var lowerLimb;
ranks bin;
run;
。我还尝试使用bin/kafka-server-start.sh
和docker exec -it zookeeper bash
浏览容器,并在docker exec -it kafka bash
目录中找到zkServer.sh和其他脚本。
问题:问题是我不知道如何使用它,因为config / server.properties在kafka容器而不是zookeeper中可用。所以我不知道适当的解决方案。下载脚本并将其放置在主机目录中并将它们复制到容器中是否是一个好的解决方案?
docker-compose.yml
/bin/
Dockerfile
version:'2'
services:
zookeeper:
image: wurstmeister/zookeeper
container_name: zookeeper
ports:
- "2181:2181"
kafka:
build: .
container_name: kafka
links:
- zookeeper
ports:
- "9092:9092"
environment:
KAFKA_ADVERTISED_HOST_NAME: kafka
KAFKA_ADVERTISED_PORT: 9092
KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
KAFKA_OPTS: -javaagent:/usr/app/jmx_prometheus_javaagent.jar=7071:/usr/app/prom-jmx-agent-config.yml
volumes:
- /var/run/docker.sock:/var/run/docker.sock
答案 0 :(得分:2)
您不必使用bin/kafka-server-start.sh
脚本。 start-kafka.sh
图像中有一个名为wurstmeister/kafka
的脚本。这是我在一个项目中所做的事情:
docker-compose.yml
zookeeper:
container_name: zookeper
image: wurstmeister/zookeeper:3.4.6
ports:
- "2181:2181"
kafka:
container_name: kafka
build:
context: .
dockerfile: kafka.Dockerfile
image: kafka-service
ports:
- "9092:9092"
kafka.Dockerfile
FROM wurstmeister/kafka:2.11-2.0.0
COPY wait-for-it.sh /wait-for-it.sh
RUN chmod +x /wait-for-it.sh
CMD ["/wait-for-it.sh", "zookeper:2181", "--", "start-kafka.sh"]
在dockerfile中,我实际上是说:“等一下动物园管理员,他必须先站起来,然后您可以开始,然后在他之后,运行start-kafka.sh
”。您可以在此处下载wait-for-it.sh脚本:https://github.com/vishnubob/wait-for-it/blob/master/wait-for-it.sh
PS:您可以使用以下命令查看任何图像的基本信息:
docker inspect <image-name>