[JAVA] If you just want to run your containers in the cloud, Azure Container Instances is easy


It was decided to use Azure for the project I'm doing now, and I was thinking of developing the screen with Java (Springboot) and deploying it in a container. You can deploy containers with AKS and WebApp on Linux, but ACI (Azure Container Instances) can be deployed more easily.

I would like to introduce the flow of deploying to Azure Container Instances using Jib for deploying to the registry.

Solution introduction

Azure Container Registry


Azure Container Instances

Push to ACR using Jib

Add plugin


plugins {
    id 'com.google.cloud.tools.jib' version '1.4.0'

Create an ACR repository and change the image name part. The user name and password should be described in gradle.properties.


jib {
    to {
        image = 'xxxxxx.azurecr.io/web'
        auth {
            username = "${USERNAME}"
            password = "${PASSWORD}"



After that, if you type a command, it will create a container and push it to ACR.

$ gradlew jib

To create only the container, type the following command. (Once the container is created, it is good to check the operation with docker run)

$ gradlew jibDockerBuild

Deploy to Container Instances

After logging in to Azure, just start Cloud Shell and type the following command.

az container create -g TEST-RG \
   --name poc-web \
   --image xxxxx.azurecr.io/web \
   --ip-address public \
   --registry-username xxxxx \
   --registry-password yyyyyyyyy \
   --ports 80 \
   --dns-name-label zzzzzzz \
   --environment-variables SPRING_PROFILES_ACTIVE=development 

Other operations on Container Instances

Get the log

az container logs --resource-group TEST-RG --name poc-web

Attach to log (leads to standard output of container)

az container attach --resource-group TEST-RG --name poc-web

Delete Containr Instances

az container delete -g TEST-RG --name poc-web 


You can monitor using Azure Monitor, but it seems that you can not see the details with CPU, memory, network In / Out. For now, I think it would be like using SideCar to monitor for more metrics.



Anyway, it's Container Instances to easily deploy a container to Azure.

Recommended Posts

If you just want to run your containers in the cloud, Azure Container Instances is easy
If you want to recreate the instance in cloud9
If you want to include the parent class in Lombok's @builder
What to do if Cloud9 is full in the Rails tutorial
If you want to satisfy the test coverage of private methods in JUnit
[Rails] What to do if you accidentally install bundle in the production environment in your local environment
What to do when you want to know the source position where the method is defined in binding.pry
If you want to mock a method in RSpec, you should use the allow method for mock and the singleton method.
ProxyFactory is convenient when you want to test AOP in Spring!
[PostgreSQL] If you want to delete the Rails app, delete the database first!
If you want to change the Java development environment from Eclipse
What to do if you forget the root password in CentOS7
If you think in your heart, "Replace the product image"! At that time, the action is over! ~ part4 ~
[RSpec] When you want to use the instance variable of the controller in the test [assigns is not recommended]
What to do if Operation not permitted is displayed when you execute a command in the terminal
What to do if the prefix c is not bound in JSP
If you want to dynamically embed values & add text to attribute values in Thymeleaf 3
[Cloud9] Yay! You ’re on Rails! Is not displayed in the rails tutorial
Install the IBM Cloud CLI in the container
Let's run batch in container using Azure Batch
You may not want to use the remove method in ArrayList very often
If you are using Android Room and want to change the column definition
What to do if you get To install the missing version, run `gem install bundler: 2.1.4`
What to do if the rails server doesn't run out on AWS cloud9
Even if I want to convert the contents of a data object to JSON in Java, there is a circular reference ...
I want you to put the story that the error was solved when you stabbed the charger in the corner of your head