英文:
How to connect to external service from an Application deployed on docker?
问题
以下是翻译好的内容:
我有一个应用程序,该应用程序正在使用嵌入式JanusGraph服务器。
当该应用程序直接部署在服务器(裸金属)上时,应用程序运行良好。
然而,当我在Docker上运行映像时,我遇到连接错误。
这是我使用的Docker文件:
FROM *****.ecr.us-east-1.***.com/java8:latest
ADD my-api/target/my-api-0.0.4-FINAL.zip /opt/
WORKDIR /opt/
RUN unzip my-api-0.0.4-FINAL.zip
WORKDIR /opt/my-api-0.0.4/bin/
RUN chmod +x /opt/my-api-0.0.4/bin/runserverscript.sh
RUN mkdir /data
EXPOSE 8181
CMD exec /opt/my-api-0.0.4/bin/runserverscript.sh
这是我连接到外部数据库的JanusGraph配置:
storage.backend=cql
storage.cql.keyspace=a_graph
storage.cql.read-consistency-level=ONE
storage.hostname=10*.**.2.**
cache.db-cache = true
cache.db-cache-clean-wait = 20
cache.db-cache-size = 0.5
cache.db-cache-time = 180000
我使用以下命令创建映像:
docker build --tag my-api:latest .
并使用以下命令运行容器:
docker run --publish 7171:7171 --name myapi my-api:latest
并且出现了以下连接问题:
正在加载...图配置:ja-staging.properties 无法启动服务器,错误:创建bean时出错,bean名称为 '':注入自动装配的依赖项失败;嵌套异常是 org.springframework.beans.factory.BeanCreationException:无法自动装配字段:私有XXXService XXXService;嵌套异常是 org.springframework.beans.factory.BeanCreationException:创建bean时出错,bean名称为 'followService':注入自动装配的依赖项失败;嵌套异常是 org.springframework.beans.factory.BeanCreationException:无法自动装配字段:私有gggService gService;嵌套异常是 org.springframework.beans.factory.BeanCreationException:创建bean时出错,bean名称为 'graphService':调用init方法失败;嵌套异常是 java.lang.IllegalArgumentException:无法实例化实现:org.janusgraph.diskstorage.cql.CQLStoreManager
英文:
I have an application which is using an embedded janusgraph server.
The application is running fine when it is deployed directly on the server (bare metal).
However, i am getting connection error when i run the image on docker.
Here is the docker file, which i am using:
FROM *****.ecr.us-east-1.***.com/java8:latest
ADD my-api/target/my-api-0.0.4-FINAL.zip /opt/
WORKDIR /opt/
RUN unzip my-api-0.0.4-FINAL.zip
WORKDIR /opt/my-api-0.0.4/bin/
RUN chmod +x /opt/my-api-0.0.4/bin/runserverscript.sh
RUN mkdir /data
EXPOSE 8181
CMD exec /opt/my-api-0.0.4/bin/runserverscript.sh
and here is the janusgraph config: (which i connecting to external db)
storage.backend=cql
storage.cql.keyspace=a_graph
storage.cql.read-consistency-level=ONE
storage.hostname=10*.**.2.**
cache.db-cache = true
cache.db-cache-clean-wait = 20
cache.db-cache-size = 0.5
cache.db-cache-time = 180000
I am creating the image using the following command:
docker build --tag my-api:latest .
and running the container using:
docker run --publish 7171:7171 --name myapi my-api:latest
and getting the connect issue as follows:
> Loading.. Graph Config : ja-staging.properties Server could not be
> started, ERROR: Error creating bean with name '': Injection of
> autowired dependencies failed; nested exception is
> org.springframework.beans.factory.BeanCreationException: Could not
> autowire field: private XXXService XXXService; nested exception is
> org.springframework.beans.factory.BeanCreationException: Error
> creating bean with name 'followService': Injection of autowired
> dependencies failed; nested exception is
> org.springframework.beans.factory.BeanCreationException: Could not
> autowire field: private gggService gService; nested exception is
> org.springframework.beans.factory.BeanCreationException: Error
> creating bean with name 'graphService': Invocation of init method
> failed; nested exception is java.lang.IllegalArgumentException: Could
> not instantiate implementation:
> org.janusgraph.diskstorage.cql.CQLStoreManager
答案1
得分: 0
重新在我的 Mac 机器上安装 Docker 解决了我的问题。
我不知道为什么会发生这种情况。但在经过几天的困扰后,我重新安装了 Docker,一切都正常工作了。
英文:
Re-installing the docker from my mac machine resolved the issue for me.
I am not why it was happening. But after a couple of days of struggler, i re-installed the docker, and all worked fine.
专注分享java语言的经验与见解,让所有开发者获益!
评论