我有一个使用vert.x的maven项目。我把所有的眩晕都部署在这样的主要类中:
package launcher;
import io.vertx.core.Vertx;
public class MainLauncher {
public static void main(String[] args) {
final Vertx vertx = Vertx.vertx();
vertx.deployVerticle(new ImportFileVerticle());
vertx.deployVerticle(new InsertFileVerticle());
vertx.deployVerticle(new ExportFileVerticle());
}
}我添加了这样的Dockerfile:
FROM maven:3.3.9-jdk-8
RUN mkdir -p /opt/app
WORKDIR /opt/app
COPY pom.xml /opt/app/pom.xml
RUN mvn install
COPY . /opt/app/
RUN mvn package
EXPOSE 8080
CMD ["mvn", "exec:java"]我在我的pom.xml中添加了这个依赖项:
<dependency>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.6.0</version>
</dependency>我使用以下命令构建映像:
码头建设-t我的应用程序。
我正在执行以下命令:
docker运行-p 8080:8080 -t -i myapp
一旦运行完成,问题就出现了,我输入:
http://localhost:8080/
什么都没发生。
或者,通过使用postman调用我的垂直项的url (localhost: 8081 / listImport)来查看我的导入列表,什么也不会发生。
注: ImportFileVerticle收听8081,InsertFileVerticle收听8082,ExportFileVerticle收听8083
一旦码头图像启动,我如何调用在这些眩晕中定义的urls?
我的第二个问题是,我有一个包含应用程序前端的对接图像,我如何将包含前端的图像与后端的图像以及包含mysql的图像进行通信?
预先感谢您的帮助
发布于 2018-07-20 19:37:28
关于我们如何运行我们的码头集装箱:
我们在创建映像时所做的是创建一个影子jar,将所有的依赖项都放在其中,然后我们在docker映像中使用该可执行jar。为此,我们使用io.vertx.core.Launcher作为我们的主要类,然后创建一个初始化垂直线来提取我们的配置和秘密,然后生成我们需要通过vertx.deployVerticle(CLASS);运行的所有其他眩晕。
或者,如果您不想做所有这些工作,可以使用维特-码头
现在回答你的问题:
-p 8080:8080这一节的停靠器运行命令声明您是端口绑定8080主机到8080在码头容器。您在上面声明您正在8081,8082,8083港口的集装箱中运行您的眩晕。如果要从主机访问它们,则必须将端口绑定到主机。- Binding the containers port to the host machine via the `-p` port mapping and setting up the other containers to connect to the host ip address and designated port. _**Please note you cannot use localhost because localhost refers to the containers localhost not host.**_
- Container linking. You could also use `--link` to create a virtual network and then link the containers that way which will create dns entries in the containers /etc/hosts file that would then put in your configuration for your services. In this case I usually use docker-compose if I'm on the same machine designating dependent containers using the `depends_on` clause. [docker-compose depends\_on](https://docs.docker.com/compose/compose-file/#depends_on)
希望这能帮上忙!
https://stackoverflow.com/questions/51315097
复制相似问题