大网数据广告活动
服务器运维问答

Docker, docker-compose application settings

· 52CE 我爱测

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 …

问题原文

原帖链接 · gogasca · CC BY-SA 3.0

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?

已采纳解答

原帖链接 · Wassim Dhif · CC BY-SA 3.0

  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.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2016-02-15)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。