Dockerの--link/Docker Composeのlinksはdeprecatedだった、気になる脱出先は? 年収は?

知らなかった……。

Warning: >The --link flag is a legacy feature of Docker. It may eventually be removed. Unless you absolutely need to continue using it, we recommend that you use user-defined networks to facilitate communication between two containers instead of using --link. One feature that user-defined networks do not support that you can do with --link is sharing environmental variables between containers. However, you can use other mechanisms such as volumes to share environment variables between containers in a more controlled way.

https://docs.docker.com/compose/compose-file/#links

どうすればいいかというと↑に書いてあるようにカスタムネットワークを追加して、それに参照しあいたいコンテナをそれに参加させたらよい。

before

---

version: '3'
services:
  api:
    build: .
    ports:
      - '8000'
  front:
    build: .
    ports:
      - '3000:3000'
    links:
      - api

after

---
version: '3'
services:
  api:
    build: .
    expose:
      - '8000'
    networks:
      - local_dev
  front:
    build: .
    ports:
      - '3000:3000'
    depends_on:
      - api
    environment:
      GRAPHQL_ENDPOINT: 'http://api:8000/api/graphql'
    networks:
      - local_dev
networks:
  local_dev:

おわり

意外とさっくり移行できて助かった。