Deploy a docker image to Azure Container Instance

sravanth 20 Reputation points
2024-01-05T17:33:17.62+00:00

I am having two docker images, one of them is an R Plumber API and the other is an R Shiny App. I follow the instructions in: https://video2.skills-academy.com/en-us/training/modules/intro-to-containers/6-deploy-docker-image-to-container-instance

Pushing the docker images from my local docker to an Azure Container Registry works fine. However, using Azure Container Instance to run the image generates the instance but the FDQN and IP address (port included) of the instances are unreachable.

I use the following command as per the learn link above: az container create --resource-group mygroup --name myinstance --image myregistry.azurecr.io/myapp:latest --dns-name-label mydnsname --registry-username <username> --registry-password <password>

When I try to deploy the image as a web app on the other hand, it works just fine!

Azure Container Instances
Azure Container Instances
An Azure service that provides customers with a serverless container experience.
672 questions
{count} votes

Accepted answer
  1. v-vvellanki-MSFT 4,915 Reputation points Microsoft Vendor
    2024-01-07T15:52:15.6866667+00:00

    Hi @sravanth,
    Thanks for contacting Microsoft Q&A platform.
    I went through the lab as well, using wordpress:latest as the container instance and didn't have any issues. Assuming the az container create completed successfully, check to make sure container instance actually deployed successfully. Did you use the correct password for the registry i.e. az acr credentials show --name myregistry? Is it in a running state? Check for any errors in the log tab of the Containers blade that may have prevented the container from starting up and receiving traffic.

    I used rocker/rstudio image which exposes port 8787 just as your docker image does. I configured the container instance with the following CLI command az container create --name qna1085919 --image .azurecr.io/qna1085919:latest --dns-name-label qna1085919 --registry-username <registry name> --registry-password <password> --environment-variables PASSWORD=demopass@1224 --ports 8787. I was then able to navigate to the instance via the 8787 port http://qna1085919.eastus.azurecontainer.io:8787/. Your setting port 443 which your app is not accepting traffic on. You should be able to adjust your docker image through the EXPOSE command i.e 8787:80 so that HTTP traffic gets forwarded to that open port. Another option is configure your docker image so that your rocker/r-base is configured to accept traffic on port 80/443.
    Hope this helps you.

    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Ahamed Musthafa Careem 386 Reputation points
    2024-01-06T02:11:38.99+00:00

    Hi, Please check the below common troubleshooting steps and let me know if this helped or not.

    • Check the entry point of your Docker container. Ensure it's correctly set up to start the R Plumber API or R Shiny App server.
    • Ensure that the Docker container exposes the correct ports. For web services like R Plumber API or R Shiny App, this is typically port 80 or 443 for HTTP/HTTPS traffic.
      When creating the container instance, you might need to explicitly specify the port using the --port argument in your az container create command.
    • Check the health and logs of the container instance. It’s possible the container is starting but then exiting due to an error. Use Azure CLI or Azure Portal to inspect the logs.
      Use the command az container logs --resource-group mygroup --name myinstance to view the logs.
    0 comments No comments