Code Monkey home page Code Monkey logo

docker-compose-azure's Introduction

Get started

This is about building containers and deploying them using Docker Compose on your local machine, respectively at Azure as a Container Instance.

For a more detailed manual please see the related blog post:

https://www.patrickkoch.dev/posts/post_20/

Prerequisites:

  • Docker Compose
  • Active Azure Subscription

Building Docker Images with Dockerfiles

After cloning the repository, the containers can be builded by using the "docker build" command.

Start e.g.: a Windows PowerShell, change the directory to "first-linux-container" and run:

docker build -t first-linux-container . 

After that, change the directory to "second-linux-container" and run:

docker build -t second-linux-container . 

This will create the container images.

Deployment of the containers using Docker Compose

Deploying the Containers on your local Machine

Change the directory to "docker-compose-yaml-files\local" and run following command:

docker compose up

This will run two containers, refering to the container images builded before. You can prove that by running:

docker ps

Terminating the Containers on your local Machine

Run following command for terminating the containers:

docker compose down

Deploying the Containers in Azure

In contrast to the previous approach, this aims to deploy the containers in Azure as Container Instance. As prerequisite for that, you need an active Azure subscription.

Login to Azure

az login

Tag the Container Images properly

Tag the container images, so they fit to be pushed to the Container Registry:

docker tag <Image ID> <Container Registry Name>.azurecr.io/containergroup:first-linux-container
docker tag <Image ID> <Container Registry Name>.azurecr.io/containergroup:second-linux-container

Login to the Container Registry and push the Container Images

Use following command to login to your Container Registry, which will manage your Container Images:

az acr login --name <Container Registry Name>

Afterwards, push the Container Images using:

docker push <Container Registry Name>.azurecr.io/containergroup:first-linux-container
docker push <Container Registry Name>.azurecr.io/containergroup:second-linux-container

Create and ACI Context and switch to the Context

Create a new ACI context by applying following command:

docker context create aci patricksacicontext

In addition, switch to that context:

docker context use patricksacicontext

Deploying the Containers in Azure as Container Instance using Docker Compose

Adapt the Docker-Compose-YAML file, due to the name of the pushed Container Images, respectively the name of the Container Registry:

version: "3.9"
services:
  first-linux-container:
    image:  <Container Registry Name>.azurecr.io/containergroup:first-linux-container
  second-linux-container:
    image:  <Container Registry Name>.azurecr.io/containergroup:second-linux-container

Afterwards, apply the very same "docker compose" commands for deploying/terminating the containers:

docker compose up
docker compose down

The containers will be deployed as an "Azure Container Instance".

docker-compose-azure's People

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.