为什么我的 docker-compose yaml 文件看不到 jar 文件?
Why my docker-compose yaml file can't see jar file?
我有这个 yaml 文件
version: '2'
services:
app1:
image: producer1
build:
context: .
ports:
- "8088:8088"
networks:
- lognet1
zookeeper:
image: wurstmeister/zookeeper
networks:
- lognet1
ports:
- "2181:2181"
kafka:
image: wurstmeister/kafka
networks:
- lognet1
ports:
- "9092:9092"
environment:
KAFKA_ADVERTISED_HOST_NAME: 192.168.99.100
KAFKA_MESSAGE_MAX_BYTES: 2000000
KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
KAFKA_AUTO_CREATE_TOPICS_ENABLE: 'false'
KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://192.168.99.100:9092
KAFKA_BROKER_ID: 0
KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: PLAINTEXT:PLAINTEXT,PLAINTEXT_HOST:PLAINTEXT
KAFKA_INTER_BROKER_LISTENER_NAME: PLAINTEXT
KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1
networks:
lognet1:
driver: overlay
和文档文件
FROM adoptopenjdk:11-jre-hotspot
ARG JAR_FILE=*.jar
COPY ${JAR_FILE} application.jar
ENTRYPOINT ["java", "-jar", "application.jar"]
和 jar 在同一个目录中,但是在 compose upping 之后它没有看到新的变化,所以它不能读取 jar,我试过 运行 它们以不同的方式工作,但是 dcoker compose 不是
运行 这个命令应该有效:
docker-compose up -d --build --force-recreate app1
否则,运行第二个命令:
docker-compose build --no-cache app1 && docker-compose up -d
我有这个 yaml 文件
version: '2'
services:
app1:
image: producer1
build:
context: .
ports:
- "8088:8088"
networks:
- lognet1
zookeeper:
image: wurstmeister/zookeeper
networks:
- lognet1
ports:
- "2181:2181"
kafka:
image: wurstmeister/kafka
networks:
- lognet1
ports:
- "9092:9092"
environment:
KAFKA_ADVERTISED_HOST_NAME: 192.168.99.100
KAFKA_MESSAGE_MAX_BYTES: 2000000
KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
KAFKA_AUTO_CREATE_TOPICS_ENABLE: 'false'
KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://192.168.99.100:9092
KAFKA_BROKER_ID: 0
KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: PLAINTEXT:PLAINTEXT,PLAINTEXT_HOST:PLAINTEXT
KAFKA_INTER_BROKER_LISTENER_NAME: PLAINTEXT
KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1
networks:
lognet1:
driver: overlay
和文档文件
FROM adoptopenjdk:11-jre-hotspot
ARG JAR_FILE=*.jar
COPY ${JAR_FILE} application.jar
ENTRYPOINT ["java", "-jar", "application.jar"]
和 jar 在同一个目录中,但是在 compose upping 之后它没有看到新的变化,所以它不能读取 jar,我试过 运行 它们以不同的方式工作,但是 dcoker compose 不是
运行 这个命令应该有效:
docker-compose up -d --build --force-recreate app1
否则,运行第二个命令:
docker-compose build --no-cache app1 && docker-compose up -d