2017-11-27 19 views
0

Vue.js + Nuxt.jsアプリケーションをコンテナ化しようとしています。奇妙なことは、私がdocker run -p 3000:3000 <image_name>を実行したときに私はアプリケーションにアクセスできるが、私はドッカーを作成するコマンドを実行するときではないということです。 docker build -t <image_name> .その後、docker run -p 3000:3000 <image_name>作品を実行し、前述のようDockerizing Nuxt.js app:docker runは動作しますが、docker-composeは実行しません。

FROM node:8.9.1-alpine 

# Create app dir 
RUN mkdir -p /usr/src/app 
WORKDIR /usr/src/app 

# Install deps 
RUN apk update && apk upgrade && apk add git 

COPY package*.json /usr/src/app/ 
RUN npm install 
# If building for production: 
# RUN npm install --only=production 
COPY . /usr/src/app/ 

ENV HOST 0.0.0.0 
EXPOSE 3000 

# Start command 
CMD [ "npm", "run", "dev" ] 

私Dockerfileは、このようになります。

docker-compose up 
Creating network "vueui_default" with the default driver 
Creating vueui_web_1 ... 
Creating vueui_web_1 ... done 
Attaching to vueui_web_1 
web_1 | 
web_1 | > [email protected] dev /usr/src/app 
web_1 | > nuxt 
web_1 | 
web_1 | 2017-11-27T06:23:52.962Z nuxt:axios BaseURL: http://localhost:3000/api (Browser: /api) 
web_1 | 2017-11-27T06:23:57.822Z nuxt:build App root: /usr/src/app 
web_1 | 2017-11-27T06:23:57.823Z nuxt:build Generating /usr/src/app/.nuxt files... 
web_1 | 2017-11-27T06:23:57.855Z nuxt:build Generating files... 
web_1 | 2017-11-27T06:23:57.883Z nuxt:build Generating routes... 
web_1 | 2017-11-27T06:23:58.018Z nuxt:build Building files... 
web_1 | 2017-11-27T06:23:58.429Z nuxt:build Adding webpack middleware... 
web_1 | ERROR Failed to compile with 3 errors06:24:28 
web_1 | 
web_1 | error in ./layouts/default.vue 
web_1 | 
web_1 | Module build failed: Error: Missing binding /usr/src/app/node_modules/node-sass/vendor/linux_musl-x64-57/binding.node 
web_1 | Node Sass could not find a binding for your current environment: Linux/musl 64-bit with Node.js 8.x 
web_1 | 
web_1 | Found bindings for the following environments: 
web_1 | - OS X 64-bit with Node.js 9.x 
web_1 | 
web_1 | This usually happens because your environment has changed since running `npm install`. 
web_1 | Run `npm rebuild node-sass --force` to build the binding for your current environment. 
web_1 |  at module.exports (/usr/src/app/node_modules/node-sass/lib/binding.js:15:13) 
web_1 |  at Object.<anonymous> (/usr/src/app/node_modules/node-sass/lib/index.js:14:35) 
web_1 |  at Module._compile (module.js:635:30) 
web_1 |  at Object.Module._extensions..js (module.js:646:10) 
web_1 |  at Module.load (module.js:554:32) 
web_1 |  at tryModuleLoad (module.js:497:12) 
web_1 |  at Function.Module._load (module.js:489:3) 
web_1 |  at Module.require (module.js:579:17) 
web_1 |  at require (internal/module.js:11:18) 
web_1 |  at Object.<anonymous> (/usr/src/app/node_modules/sass-loader/lib/loader.js:3:14) 
web_1 |  at Module._compile (module.js:635:30) 
web_1 |  at Object.Module._extensions..js (module.js:646:10) 
web_1 |  at Module.load (module.js:554:32) 
web_1 |  at tryModuleLoad (module.js:497:12) 
web_1 |  at Function.Module._load (module.js:489:3) 
web_1 |  at Module.require (module.js:579:17) 
web_1 | 
web_1 | @ ./node_modules/vue-style-loader?{"sourceMap":true}!./node_modules/css-loader?{"minimize":true,"importLoaders":1,"sourceMap":true,"alias":{"/static":"/usr/src/app/static","/assets":"/usr/src/app/assets"}}!./node_modules/vue-loader/lib/style-compiler?{"vue":true,"id":"data-v-314f53c6","scoped":false,"hasInlineConfig":true}!./node_modules/sass-loader/lib/loader.js?{"indentedSyntax":true}!./node_modules/vue-loader/lib/selector.js?type=styles&index=0&bustCache!./layouts/default.vue 4:14-499 13:3-17:5 14:22-507 
web_1 | @ ./layouts/default.vue 
web_1 | @ ./node_modules/babel-loader/lib?{"babelrc":false,"cacheDirectory":true,"presets":["/usr/src/app/node_modules/babel-preset-vue-app/dist/index.common.js"]}!./node_modules/vue-loader/lib/selector.js?type=script&index=0&bustCache!./.nuxt/App.vue 
web_1 | @ ./.nuxt/App.vue 
web_1 | @ ./.nuxt/index.js 
web_1 | @ ./.nuxt/client.js 
web_1 | @ multi webpack-hot-middleware/client?name=client&reload=true&timeout=3000&path=/__webpack_hmr ./.nuxt/client.js 
web_1 | 
web_1 | error in ./layouts/plain.vue 
web_1 | 
web_1 | Module build failed: Error: Missing binding /usr/src/app/node_modules/node-sass/vendor/linux_musl-x64-57/binding.node 
web_1 | Node Sass could not find a binding for your current environment: Linux/musl 64-bit with Node.js 8.x 
web_1 | 
web_1 | Found bindings for the following environments: 
web_1 | - OS X 64-bit with Node.js 9.x 
web_1 | 
web_1 | This usually happens because your environment has changed since running `npm install`. 
web_1 | Run `npm rebuild node-sass --force` to build the binding for your current environment. 
web_1 |  at module.exports (/usr/src/app/node_modules/node-sass/lib/binding.js:15:13) 
web_1 |  at Object.<anonymous> (/usr/src/app/node_modules/node-sass/lib/index.js:14:35) 
web_1 |  at Module._compile (module.js:635:30) 
web_1 |  at Object.Module._extensions..js (module.js:646:10) 
web_1 |  at Module.load (module.js:554:32) 
web_1 |  at tryModuleLoad (module.js:497:12) 
web_1 |  at Function.Module._load (module.js:489:3) 
web_1 |  at Module.require (module.js:579:17) 
web_1 |  at require (internal/module.js:11:18) 
web_1 |  at Object.<anonymous> (/usr/src/app/node_modules/sass-loader/lib/loader.js:3:14) 
web_1 |  at Module._compile (module.js:635:30) 
web_1 |  at Object.Module._extensions..js (module.js:646:10) 
web_1 |  at Module.load (module.js:554:32) 
web_1 |  at tryModuleLoad (module.js:497:12) 
web_1 |  at Function.Module._load (module.js:489:3) 
web_1 |  at Module.require (module.js:579:17) 
web_1 | 
web_1 | @ ./node_modules/vue-style-loader?{"sourceMap":true}!./node_modules/css-loader?{"minimize":true,"importLoaders":1,"sourceMap":true,"alias":{"/static":"/usr/src/app/static","/assets":"/usr/src/app/assets"}}!./node_modules/vue-loader/lib/style-compiler?{"vue":true,"id":"data-v-1215e3b4","scoped":false,"hasInlineConfig":true}!./node_modules/sass-loader/lib/loader.js?{"indentedSyntax":true}!./node_modules/vue-loader/lib/selector.js?type=styles&index=0&bustCache!./layouts/plain.vue 4:14-497 13:3-17:5 14:22-505 
web_1 | @ ./layouts/plain.vue 
web_1 | @ ./node_modules/babel-loader/lib?{"babelrc":false,"cacheDirectory":true,"presets":["/usr/src/app/node_modules/babel-preset-vue-app/dist/index.common.js"]}!./node_modules/vue-loader/lib/selector.js?type=script&index=0&bustCache!./.nuxt/App.vue 
web_1 | @ ./.nuxt/App.vue 
web_1 | @ ./.nuxt/index.js 
web_1 | @ ./.nuxt/client.js 
web_1 | @ multi webpack-hot-middleware/client?name=client&reload=true&timeout=3000&path=/__webpack_hmr ./.nuxt/client.js 
web_1 | 
web_1 | error in ./layouts/public.vue 
web_1 | 
web_1 | Module build failed: Error: Missing binding /usr/src/app/node_modules/node-sass/vendor/linux_musl-x64-57/binding.node 
web_1 | Node Sass could not find a binding for your current environment: Linux/musl 64-bit with Node.js 8.x 
web_1 | 
web_1 | Found bindings for the following environments: 
web_1 | - OS X 64-bit with Node.js 9.x 
web_1 | 
web_1 | This usually happens because your environment has changed since running `npm install`. 
web_1 | Run `npm rebuild node-sass --force` to build the binding for your current environment. 
web_1 |  at module.exports (/usr/src/app/node_modules/node-sass/lib/binding.js:15:13) 
web_1 |  at Object.<anonymous> (/usr/src/app/node_modules/node-sass/lib/index.js:14:35) 
web_1 |  at Module._compile (module.js:635:30) 
web_1 |  at Object.Module._extensions..js (module.js:646:10) 
web_1 |  at Module.load (module.js:554:32) 
web_1 |  at tryModuleLoad (module.js:497:12) 
web_1 |  at Function.Module._load (module.js:489:3) 
web_1 |  at Module.require (module.js:579:17) 
web_1 |  at require (internal/module.js:11:18) 
web_1 |  at Object.<anonymous> (/usr/src/app/node_modules/sass-loader/lib/loader.js:3:14) 
web_1 |  at Module._compile (module.js:635:30) 
web_1 |  at Object.Module._extensions..js (module.js:646:10) 
web_1 |  at Module.load (module.js:554:32) 
web_1 |  at tryModuleLoad (module.js:497:12) 
web_1 |  at Function.Module._load (module.js:489:3) 
web_1 |  at Module.require (module.js:579:17) 
web_1 | 
web_1 | @ ./node_modules/vue-style-loader?{"sourceMap":true}!./node_modules/css-loader?{"minimize":true,"importLoaders":1,"sourceMap":true,"alias":{"/static":"/usr/src/app/static","/assets":"/usr/src/app/assets"}}!./node_modules/vue-loader/lib/style-compiler?{"vue":true,"id":"data-v-1eea6a3d","scoped":false,"hasInlineConfig":true}!./node_modules/sass-loader/lib/loader.js?{"indentedSyntax":true}!./node_modules/vue-loader/lib/selector.js?type=styles&index=0&bustCache!./layouts/public.vue 4:14-498 13:3-17:5 14:22-506 
web_1 | @ ./layouts/public.vue 
web_1 | @ ./node_modules/babel-loader/lib?{"babelrc":false,"cacheDirectory":true,"presets":["/usr/src/app/node_modules/babel-preset-vue-app/dist/index.common.js"]}!./node_modules/vue-loader/lib/selector.js?type=script&index=0&bustCache!./.nuxt/App.vue 
web_1 | @ ./.nuxt/App.vue 
web_1 | @ ./.nuxt/index.js 
web_1 | @ ./.nuxt/client.js 
web_1 | @ multi webpack-hot-middleware/client?name=client&reload=true&timeout=3000&path=/__webpack_hmr ./.nuxt/client.js 

私が間違ってやっているかもしれないものを任意のアイデア:次のエラーでdocker-compose up結果を実行している

version: '3' 
services: 
    web: 
    build: . 
    ports: 
    - "3000:3000" 
    volumes: 
    - .:/usr/src/app 

:以下ドッキングウィンドウ-compose.ymlファイルとただし

、?

ありがとうございます!

EDIT:

私はので、私は(それゆえメッセージOS X 64-bit with Node.js 9.x)モジュールがどうにか影響を受ける可能性があるかもしれないと思った地域開発のためのMacOSを使用しています。しかし、私は私の.dockerignoreに次のように持っているので、これはケースではありません。

node_modules 
npm-debug.log 

答えて

0

私はこの問題を解決することができました。問題は、他のスレッドが言及として、次のコマンドは、コンテナ内で実行する必要があるということである。

npm rebuild node-sass 

これは私の地元のdevの環境(MacOSの)とドッカーコンテナ(Linuxの)の違いによるものです。

bashが高山ではデフォルトでは存在しないので、これは使用容器に滴下することによって行うことができる。

docker exec -it <image_name> /bin/sh 
関連する問題