我要得到”
There was an unexpected error (type=Internal Server Error, status=500) GENERAL
“在Docker容器中部署zuul网关服务并进行测试时出错。但是在Windows中,当我在Eclipse中运行应用程序时,一切都正常工作,我可以通过zuul网关端口访问服务,还可以通过网关使用与邮递员之间的每个映射。但它在码头集装箱里不起作用。
zuulgatewayserveradication.java;
@EnableEurekaClient
@EnableZuulProxy
@SpringBootApplication
@EnableDiscoveryClient
public class ZuulGatewayServerApplication {
public static void main(String[] args) {
SpringApplication.run(ZuulGatewayServerApplication.class, args);
}
}
zuul网关服务的application.properties文件;
server.port=8762
spring.application.name=t-zuul-server
eureka.client.serviceUrl.defaultZone=http://localhost:8761/eureka
zuul.ignored-services=*
zuul.routes.t-author-bookstore.path=/author/**
zuul.routes.t-author-bookstore.service-ıd=t-author-bookstore
#zuul.routes.t-author-bookstore.strip-prefix=false
zuul.routes.t-book-bookstore.path=/book/**
zuul.routes.t-book-bookstore.service-ıd=t-book-bookstore
#zuul.routes.t-book-bookstore.strip-prefix=false
#... there is also 4 more services
我还尝试在zuul网关服务的application.properties文件中添加这些代码;
eureka.client.registerWithEureka = true
eureka.client.register-with-eureka=true
ribbon.eureka.enabled=true
zuul.routes.${service_name}.strip-prefix=false
在Docker中,对于zuul网关服务,我的dockerfile是这样的
FROM openjdk:8-alpine
VOLUME /tmp
COPY t-zuul-gateway-server-1.0.jar t-zuul-app.jar
EXPOSE 8762
ENTRYPOINT ["java", "-Djava.security.egd=file:/dev/./urandom", "-jar", "/t-zuul-app.jar"]
这就是我如何启动Docker Images
docker run -d --network=bookstore-mongodb -p 8761:8761 --name t-eureka-server t-eureka-server-1.0
docker run -d --network=bookstore-mongodb -p 8762:8762 --name t-zuul-servicee --link=mongo --rm -e EUREKA_CLIENT_SERVICEURL_DEFAULTZONE=http://localhost:8761/eureka t-zuul-gateway-server-1.0
docker run -d --network=bookstore-mongodb -p 8052:8052 --name t-book-bookstore --link=mongo --rm -e EUREKA_CLIENT_SERVICEURL_DEFAULTZONE=http://localhost:8761/eureka t-book-bookstore-1.0
端口8052按预期工作。
这是我的Docker容器进程的外观(Docker PS):
here
我还尝试将zuul网关服务与其他容器链接——link。但它不起作用。
同样的代码在Windows中也可以正常工作,但在Docker容器中则不行。我希望将网关与Docker容器中的服务连接起来。谢谢你的点击。