Docker-compose with django could not translate host name “db” to address: Name or service not known

后端 未结 4 775
情书的邮戳
情书的邮戳 2020-12-10 01:57

I have currently a system built with docker-compose, it creates a Django application.

Up until now I\'ve used a database inside a container (postgresql) in my testin

4条回答
  •  遥遥无期
    2020-12-10 02:36

    Add network, link and depends_on configuration in docker compose file.

    example:

      services:
          db:
              build: .
              container_name: db
              networks:
                  - djangonetwork
          web:
              build: .
              depends_on:
                 - db
              links:
                 - db:db
              networks:
                 - djangonetwork
    
      networks:
          djangonetwork:
              driver: bridge
    

提交回复
热议问题