Create/Deploy Azure Services using Docker Container

ALPHA99 1 Reputation point
2022-01-25T05:46:43.56+00:00

Suppose I have my infrastructure as a code folder where I also use Azure for my infrastructure, and terraform state is also stored on azure in a storage account on a resource group with subdirectories for each of my environments and tfvar file for each environment.

I am planning to deploy/create Azure services using Docker Container using following steps:

  1. Create a docker file where I would use terraform as base image and add terraform IaC folder to the image's filesystem.
  2. When we would run the image on docker desktop it would create a docker container.
  3. Further when Docker container would be executed , azure services would be start creating.
    Thus, When the individuals would use they would only execute and in result would get their services created in automation without getting to know the code executed.

A) Is the steps mentioned above the right way to execute the problem statement ?
B) How to create and what should , I store in the Docker Images ?
C) How to create and what should , I store in the Docker Containers ?
D) When Executing the Docker Container from Docker Desktop , How would the services get created and deployed ?
E) Suggest me on the ways I could implement the above problem statement and If not Why?

Azure Container Instances
Azure Container Instances
An Azure service that provides customers with a serverless container experience.
757 questions
Azure Lab Services
Azure Lab Services
An Azure service that is used to set up labs for classrooms, trials, development and testing, and other scenarios.
308 questions
Azure Kubernetes Service
Azure Kubernetes Service
An Azure service that provides serverless Kubernetes, an integrated continuous integration and continuous delivery experience, and enterprise-grade security and governance.
2,456 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. srbhatta-MSFT 8,586 Reputation points Microsoft Employee
    2022-01-27T16:58:39.977+00:00

    Hi @ALPHA99 ,

    A) Is the steps mentioned above the right way to execute the problem statement ?

    • Add the terraform init, plan, apply operations in the CMD directives in your docker file.

    B) How to create and what should , I store in the Docker Images ?

    • To create docker file you will have to run docker build -t <image-tag> /path/to/dockerfile command, please refer to this link Docker build.
    • You can have a COPY for the terraform templates for your infrastructure in the docker file which should get stored in one of the image layers.
    • It would be highly recommended not to store Azure credentials or any sensitive information in the docker image. You can instead pass them as environment variables.

    C) How to create and what should , I store in the Docker Containers ?

    • To create docker container , use the following code docker run image with appropriate options.
    • Containers should be preferably stateless in nature.

    D) When Executing the Docker Container from Docker Desktop , How would the services get created and deployed ?

    • The CMD instructions in the docker file, as mentioned previously would execute the terraform commands on container start. Please refer to CMD-docker-docs.

    E) Suggest me on the ways I could implement the above problem statement and If not Why?

    • Please follow the above instructions and you can also try referring to reference.

    I hope this helps.

    Please 'Accept as Answer' if the information provided was useful to help the community.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.