LoginSignup
0
0

More than 3 years have passed since last update.

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

Last updated at Posted at 2021-02-10

結論: 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
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0