2/29 -1

複数のコンテナを作るためにDockerfileを分ける

 

ファイル構造

  • reactdjango
    • docker-compose.yaml
    • docker
      • react
        • Dockerfile

 

docker-compose.yaml

  • version : '3.9'
  • services:
    • react-app
      • build:
        • context: .
        • dockerfile: ./docker/react/Dockerfile
      • volumes :
        • - ./reactApp : usr/src/app
      • command : sh -c "cd react-sample && yarn start"
      • ports:
        • -"3000:3000"
      • stdin_open :true

 

課題

この程度の規模なら問題はないがDockerデーモンに多くのファイルを送ることになる(「context: . 」による)のは処理が大きくなる問題がありそう

 

servicesの各要素続き

  • ports: "3000:3000"
    • ポートをホスト(左)で3000、コンテナ(右で)3000を使用