3

I'm starting to migrate my Application to Docker containers: I use Ngnix, supervisord, gunicorn, python flask, celery, flower, lighttpd, RabbitMQ and Postgresql. In my original virtual machine, I keep all my configurations under /usr/local/src/application/conf/ In settings.py I define my:

SQLALCHEMY_DATABASE_URI

In celeryconfig.py I define:

BROKER_URL

I will create 5 containers:

  • Ngnix load balancer
  • Flask API
  • Celery
  • RabbitMQ
  • Lighttpd

I'm using docker-compose and volumes. Since right now all my IP addresses are localhost (127.0.0.1)

  1. What's the recommendation for each of my containers to access a common configuration? Volumes?

  2. How do I know which IP address is assigned to each container so I can define my settings? For example when RabbitMQ starts what IP should I configure in BROKER_URL?

  3. Since my Docker application will still point to my git repo can I point it to my host folder, should I use volumes here?

Infrastructure

gogasca
  • 313
  • 2
  • 15

1 Answers1

4
  1. Regarding your configuration, you can pass in compose environment variable using env_file for a file or environment directly: https://docs.docker.com/compose/compose-file/#env-file
  2. For the IP, when you link containers in Compose, the name of the container you set in your yml will be the hostname of this container. You don't need an IP, just the username. You can try this by doing exec bash in a compose container and trying to ping an other container with its name.
  3. What do you mean by 'pointing to your host folder?', try to put as much as you can directly in the container, but if you really need to extract some data to your host FS, then yes you will need volumes.
Wassim Dhif
  • 166
  • 6