使用docker构build的离子项目不会加载静态文件

我有一个离子项目已经工作和运行。 我想dockerize它,所以我写了手动添加Dockerfile和.dockerignore。 我的项目结构如下所示:

在这里输入图像说明

我的package.json:

{ "name": "example", "version": "1.1.1", "description": "example: An Ionic project", "dependencies": { "angular-messages": "^1.5.1", "gulp": "^3.5.6", "gulp-concat": "^2.2.0", "gulp-minify-css": "^0.3.0", "gulp-rename": "^1.2.0", "gulp-sass": "^2.0.4" }, "devDependencies": { "bower": "^1.3.3", "gulp-util": "^2.2.14", "shelljs": "^0.3.0" }, "cordovaPlugins": [ "cordova-plugin-device", "cordova-plugin-console", "cordova-plugin-whitelist", "cordova-plugin-splashscreen", "cordova-plugin-statusbar", "ionic-plugin-keyboard" ], "cordovaPlatforms": [ "android" ] } 

我的bower.json:

 { "name": "HelloIonic", "private": "true", "dependencies": { "angular": "~1.3.1", "angular-route": "~1.3.1", "angular-cookies": "~1.4.0", "bootstrap": "~3.3.0", "bootstrap-material-design": "~0.1.5", "jquery": "~2.1.1", "ngDialog": "~0.3.3", "underscore": "~1.7.0", "ionic": "^1.2.4", "angular-resource": "^1.5.2", "angular-google-chart": "^0.1.0", "angular-ui-router-styles": "^1.1.0", "angular-audio": "^1.7.2" }, "resolutions": { "angular": "~1.3.1" } } 

我的Dockerfile:

 FROM node:4.0 COPY . /www/app RUN npm install -g ionic cordova RUN npm install -g bower RUN npm install -g gulp WORKDIR /www/app RUN npm install RUN echo '{"allow_root":true}' > /root/.bowerrc RUN bower install EXPOSE 8100 35729 ENTRYPOINT ["ionic"] CMD ["serve", "--all", "--port", "8100", "--livereload-port", "35729"] 

和.dockerignore:

 Dockerfile config.xml .sass-cache .editorconfig .io-config.json .dockerignore hooks/ platforms/ node_modules/ resources/ plugins/ www/css/*.css *.zip *.tar* 

它build成(我猜,因为没有错误),但是当我执行docker build -t ionic-preview . 但是当我运行docker run -p 8100:8100 -it ionic-preview it docker run -p 8100:8100 -it ionic-preview – >它运行但没有静态文件加载。

我的dockerfile有什么问题吗? 或者是什么问题?

更新:当通常我运行我的应用程序,我看到如下: 在这里输入图像说明

用docker工人看到这个: 在这里输入图像说明

您尚未共享您的数据,如: -v /src/webapp:/webapp

所以你可以这样做:

 docker run -p 8100:8100 -v /src/webapp:/webapp -it ionic-preview 

将地图更改为您的地图。

来源: https : //docs.docker.com/engine/tutorials/dockervolumes/#locating-a-volume