How to make redis BROKER_URL dynamic on deployment to AWS instance

I’m deploying a Django app which uses celery task and has redis as the broker backend. I’m using docker for deployment and my production server is an amazon aws instance. The problem I’m facing is that the django settings is different for localhost:

BROKER_URL = 'redis://localhost:6379'
CELERY_RESULT_BACKEND = 'redis://localhost:6379'

  • Django rest project dockerfile
  • “Invalid configuration for registry” error when executing “eb local run”
  • How to resolve Forbidden 403 error when making a urllib request with POST data in Django using Docker?
  • Docker filling up my SSD with containers when I stop an AWS server?
  • Docker Error - “jq: error: Cannot iterate over null”
  • Nginx not serving static files with docker-compose and django (13: Permission denied)
  • and all my unit tests work. For docker it fails unless I change it to

    BROKER_URL = 'redis://redis:6379'
    CELERY_RESULT_BACKEND = 'redis://redis:6379'

    My question is, how do I identify the redis broker url in my deployment server? Will it be redis://redis:6379?

    PS: For heroku server there’s an add-on for identifying the redis url call REDISTOGO_URL. Is there something similar for amazon aws server?

  • What is a good style to deploy with docker when docker hub is not available?
  • Do Dockerfile WORKDIR, ENTRYPOINT, VOLUME … apply to child images?
  • Can not delete a docker image because repository is missing
  • docker-machine ls shows state timeout whenever another docker machine is created
  • Limit Disk usage in Docker+MongoDB
  • Persistent mysql data from docker container
  • One Solution collect form web for “How to make redis BROKER_URL dynamic on deployment to AWS instance”

    BROKER_URL = ‘redis://localhost:6379’
    CELERY_RESULT_BACKEND = ‘redis://localhost:6379’

    The above implies that both redis and celery are running on localhost, the same machine on which your django app is running.

    Please check:

    1) Redis is installed on the server, and is running. (sudo service redis-server start)

    2) Celery is installed on the server, and is running.

    BROKER_URL = ‘redis://redis:6379’
    CELERY_RESULT_BACKEND = ‘redis://redis:6379’

    If you are using docker, the above implies that there is another docker container which is running redis, and your code container is linked to the redis container with the alias ‘redis’

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.