首页 > 解决方案 > 端口映射不适用于 mac 上的 docker

问题描述

我正在尝试为 spring boot 应用程序运行 docker 容器,但是我无法访问该应用程序。

我在 mac 上使用以下版本的 docker

Mac OS Mojave 版本

10.14.3 (18D109)

mac上的Docker版本:

anhs-MBP:spring-boot-with-fargate anhtrang$ docker --version
Docker version 18.09.2, build 6247962

我检查了容器日志和spring boot应用程序正常启动

容器日志:

019-08-12 01:08:42.885  INFO 6 --- [           main] o.s.j.e.a.AnnotationMBeanExporter        : Registering beans for JMX exposure on startup
2019-08-12 01:08:43.026  INFO 6 --- [           main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat started on port(s): 8080 (http)
2019-08-12 01:08:43.045  INFO 6 --- [           main] c.e.s.SpringBootWithFargateApplication   : Started SpringBootWithFargateApplication in 8.06 seconds (JVM running for 9.107)

启动 docker 容器的命令:

anhs-MBP:spring-boot-with-fargate anhtrang$ docker run -d -p 8080:8080 anhtrang/spring-boot-with-farget:0.0.1-SNAPSHOT

我还尝试在容器之外启动 Spring Boot 应用程序,它运行良好。我只是不明白为什么它不能暴露端口

我的 GitHub 存储库:

https://github.com/anhtv08/spring-boot-with-fargate

感谢任何快速帮助

标签: amazon-web-servicesspring-bootdocker

解决方案


推荐阅读