Step By Step
1、IDEA建立微服務應用
2、編輯Dockerfile
3、Build 鏡像
4、Docker Run釋出鏡像
5、開啟ECS網絡安全組,實作外部通路
1.1 建立項目

1.2 添加Controller
Code Sample
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class HelloController {
@RequestMapping("/hello")
public String Hello()
{
return "hello world!";
}
}
1.3 本地啟動測試
1.4 maven 打包應用
FROM java:8
ADD demo-0.0.1-SNAPSHOT.jar /docker-test.jar
EXPOSE 8080
ENTRYPOINT ["java","-jar","/docker-test.jar"]
3.1 建立一個目錄,下面存放jar包和Dockerfile檔案
3.2 build image
docker build -t docker-test:0.1 .
4.1 後端啟動容器
docker run -d -p 8080:8080 docker-test:0.1
4.2 本地通路:curl localhost:8080/hello
5.1 安全組放行
5.2 公網通路測試