0

I have dockerized a Django project with Postgres, Gunicorn, and Nginx following this tutorial.

Now i want to move the application to azure container instances. Can i simply create a container group following this tutorial, and expect the container images to communicate the right way?

To run the project locally i use docker-compose -f docker-**compose.prod.yml** up -d --build But how is the communication between the containers handled in azure container instances?

The docker-compose.prod.yml looks like this:

version: '3.7'

services:
  web:
    build:
      context: ./app
      dockerfile: Dockerfile.prod
    command: gunicorn hello_django.wsgi:application --bind 0.0.0.0:8000
    volumes:
        - static_volume:/home/app/web/staticfiles
        - media_volume:/home/app/web/mediafiles
    expose:
        - 8000
    env_file:
        - ./.env.prod
    depends_on:
        - db
  db:
    image: postgres:12.0-alpine
    volumes:
        - postgres_data:/var/lib/postgresql/data/
    env_file:
        - ./.env.prod.db
  nginx:
    build: ./nginx
    volumes:
        - static_volume:/home/app/web/staticfiles
        - media_volume:/home/app/web/mediafiles
    ports:
        - 1337:80
    depends_on:
        - web

volumes:
  postgres_data:
  static_volume:
  media_volume:
surendra kumar
  • 1,686
  • 11
  • 15
Pawder
  • 3
  • 2

1 Answers1

0

The containers will be able to communicate with each others using the services names (web, db, nginx) because they are part of the container group's local network. Also, take a look at the documentation as you can't use docker-composes file directly unless you use the edge version of Docker Desktop.

On another note, upon restarting, you will loose whatever you stored in your volumes because you are not using some kind of external storage. Look at the documentation.

CSharpRocks
  • 6,791
  • 1
  • 21
  • 27