当docker运行jhipster应用程序映像

时间:2018-04-17 15:41:10

标签: docker jhipster

我的jhipster后端应用程序使用mysql和elasticsearch,我使用" ./ mvnw包构建了一个docker镜像-Pprod dockerfile:build -DskipTests"成功,然后我登录并将图像推送到私人注册表,然后在生产Centos 7上,我登录该注册表并成功拉动图像。 然后我发出命令" Docker运行iamgeid"与sudo,并有以下例外:

2018-04-17 15:28:42.613  INFO 6 --- [           main] com.james.app.HdBackApp                  : The following profiles are active: prod
2018-04-17 15:28:50.061  INFO 6 --- [           main] com.james.app.config.WebConfigurer       : Web application configuration, using profiles: prod
2018-04-17 15:28:50.072  INFO 6 --- [           main] com.james.app.config.WebConfigurer       : Web application fully configured
2018-04-17 15:28:52.201 ERROR 6 --- [           main] com.zaxxer.hikari.pool.HikariPool        : HikariPool-1 - Exception during pool initialization.

com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure

The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)

在官方网站:https://www.jhipster.tech/docker-compose/,我注意到命令:

docker-compose -f src/main/docker/app.yml up

然而在制作时,没有这样的文件,我的问题是(在我的情况下): 1.是否有一个命令供所有人运行后端,包括自动拉依赖,如mysql,elasticsearch等 2.如果没有这样的命令,运行应用程序的详细方法是什么,注意:在构建映像之前,我已在docker文件夹下的文件中设置了正确的参数(如app.yml,mysql.yml等)。

谢谢和问候!

1 个答案:

答案 0 :(得分:3)

您的错误意味着您的应用程序无法找到MySQL数据库。

在制作中,如果你只有Docker,而且没有Docker Compose,你需要手动:

  • 使用适当的环境var在特定的Docker Network中启动MySQL容器,以创建用户和数据库
  • 在同一个网络中启动您的Elasticsearch容器
  • 在同一个网络中启动您的Application容器,其中包含与MySQL和Elasticsearch相关的所有特定Spring配置

这将是大var ladderLength = function(beginWord, endWord, wordList) { wordList = new Set(wordList); var str = [beginWord]; var queue = [], distance = 0, i, j, len; len = beginWord.length; queue.push(beginWord); while (queue.length > 0) { var currentWord = queue.shift(); if (currentWord === endWord) { console.log(str.join(" -> ")); return distance + 1; } for (i = 0; i < len; i++) { var tempCh = currentWord[i]; for (j = 'a'; j <= 'z'; j = String.fromCharCode(j.charCodeAt(0)+1)) { currentWord = currentWord.replaceAt(i,j); if (wordList.has(currentWord)) { distance++; wordList.delete(currentWord); str.push(currentWord); queue.push(currentWord); } } currentWord = currentWord.replaceAt(i, tempCh); } } return 0; }; String.prototype.replaceAt=function(index, replacement) { return this.substr(0, index) + replacement+ this.substr(index + replacement.length); } 命令。

所以,拥有Docker-Compose也更好,所以你在这个app.yml文件中拥有所有这些默认配置。 只需将app.yml,mysql.yml和elasticsearch.yml放入生产环境即可。别忘了自定义它们,因为我们提供了一个基本配置来帮助用户启动。

您也可以使用docker run...尝试docker-compose子生成器。如需更高级的使用,请尝试Rancher或Kubernetes。