現在Dockerの学習を通してDockerでReactアプリケーションを動かしたいと思っております.
まず下記の手順を行いました.
$ create-react-app docker-sample-app --template typescript $ cd docker-sample-app $ touch Dockerfile ; touch docker-compose.yml
Dockerfileとdocker-compose.ymlは次のよう定義しました.
FROM node:12.19.0-alpine WORKDIR /usr/src/app
version: "3" services: web: image: sample:latest container_name: sample build: context: . dockerfile: Dockerfile volumes: - ./:/usr/src/app command: "yarn && yarn start" ports: - "3000:3000"
そして下記のコマンドを実行して立ち上がると思ったのですが,うまくいません
$ docker-compose build $ docker-compose up
Attaching to sample sample | yarn install v1.22.5 sample | [1/4] Resolving packages... sample | [2/4] Fetching packages... sample | info fsevents@2.1.2: The platform "linux" is incompatible with this module. sample | info "fsevents@2.1.2" is an optional dependency and failed compatibility check. Excluding it from installation. sample | info fsevents@1.2.11: The platform "linux" is incompatible with this module. sample | info "fsevents@1.2.11" is an optional dependency and failed compatibility check. Excluding it from installation. sample | [3/4] Linking dependencies... sample | warning " > @testing-library/user-event@7.2.1" has unmet peer dependency "@testing-library/dom@>=5". sample | [4/4] Building fresh packages... sample | Done in 493.68s. sample | yarn run v1.22.5 sample | $ react-scripts start sample | ℹ 「wds」: Project is running at http://172.30.0.2/ sample | ℹ 「wds」: webpack output is served from sample | ℹ 「wds」: Content not from webpack is served from /usr/src/app/public sample | ℹ 「wds」: 404s will fallback to / sample | Starting the development server... sample | sample | Done in 13.26s. sample exited with code 0
よくわからないこと
- なぜvolumesでマウントしているのにうまく動いていないのか?
docker-compose up
をすると終了してエラーが出るまで8分ぐらいかかった.
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。