运行 spring 在 Azure 容器注册表实例上启动应用程序

run spring boot application on azure container registry instance

我正在尝试 运行 spring 在 Azure 上启动应用程序。这就是我要实现的目标:

本地项目 > Azure Devops Git Repos > Azure 容器注册表

我从本地将更改推送到 Azure Devops Repos。存储库有一个执行 maven 打包、创建 docker 图像并将图像推送到 Azure 容器注册表的管道。我正在 运行 使用 Azure 容器实例创建容器映像。容器实例部署成功,但是当我尝试访问 spring 引导应用程序中定义的 rest api 时,没有任何反应。页面继续加载。

我尝试像这样访问 GET api:

my_public_ip:8080/你好

Docker文件:

FROM openjdk:8
VOLUME /tmp
ADD target/command-center.jar command-center.jar
EXPOSE 8080
ENTRYPOINT ["java", "-jar", "/command-center.jar"]

蔚蓝-pipeline.yaml

# Docker
# Build and push an image to Azure Container Registry
# https://docs.microsoft.com/azure/devops/pipelines/languages/docker

trigger:
- master

resources:
- repo: self

variables:
  # Container registry service connection established during pipeline creation
  dockerRegistryServiceConnection: 'f4031dc5-3c27-4f41-be8c-2abdf064eaf2'
  imageRepository: 'commandcenter'
  containerRegistry: 'sapcemission.azurecr.io'
  dockerfilePath: '**/command-center/Dockerfile'
  tag: '$(Build.BuildId)'
  
  # Agent VM image name
  vmImageName: 'ubuntu-latest'

stages:
- stage: Build
  displayName: Build and push stage
  jobs:  
  - job: Build
    displayName: Build
    pool:
      vmImage: $(vmImageName)
    steps:
    - task: Maven@3
      inputs:
        mavenPomFile: 'pom.xml'
        publishJUnitResults: true
        testResultsFiles: '**/surefire-reports/TEST-*.xml'
        javaHomeOption: 'JDKVersion'
        mavenVersionOption: 'Default'
        mavenAuthenticateFeed: false
        effectivePomSkip: false
        sonarQubeRunAnalysis: false
    - task: Docker@2
      displayName: Build and push an image to container registry
      inputs:
        command: buildAndPush
        repository: $(imageRepository)
        dockerfile: $(dockerfilePath)
        containerRegistry: $(dockerRegistryServiceConnection)
        tags: |
          $(tag)

Azure 容器实例设置:

我做错了什么?

Azure 容器实例不支持像 docker 这样的端口映射。因此,在您设置 ACI 时,端口 属性 应设置为 8080(不是默认的 80)。