0
Help us understand the problem. What are the problem?

More than 1 year has passed since last update.

posted at

updated at

docker-compose could not translate host name "db" to address: Name or service not known

結論: networksで外部ネットワークを指定している場合は、中のnetworkについての default も指定しておくこと。

例えば、webプロキシーサーバーを外部コンテナで立てていてnewtworks externalで参照している場合に、中のdbをhostとして参照するとき必要(かもしれない)。

services:
  app:
    build: .
    volumes:
      - .:/app
    depends_on:
      - db
    networks:
      - default        # <- これです
      - proxy_network
    environment:
      RAILS_ENV: development

  db:
    image: postgres:11
    environment:
      - POSTGRES_PASSWORD=password
    volumes:
      - db_data:/var/lib/postgresql/data

volumes:
  db_data:

networks:
  proxy_network:
    external: true
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Sign upLogin
0
Help us understand the problem. What are the problem?