Linking django and mysql containers using docker-compose

后端 未结 3 1879
温柔的废话
温柔的废话 2021-01-01 22:18

I\'ve been following with the docker-compose tutorial here (linking django and postgres container). Although I was able to go through with the tutorial I\'m however not able

3条回答
  •  悲&欢浪女
    2021-01-01 22:50

    you don't need to worry about environment variable. When linking containers together you just use the container alias defined by the link as if it was the hostname.

    for instance if your docker-compose.yml file were:

    db:
      image: postgres
    web:
      build: .
      command: python manage.py runserver 0.0.0.0:8000
      volumes:
        - .:/code
      ports:
        - "8000:8000"
      links:
        - db:mydb
    

    In your django settings you would have to set the database host to mydb.

提交回复
热议问题