我有一个简单的网页应用程序,有一个index.html,app.js和package.json文件.
现在,我想通过一个码头集装箱运行它。在我的本地机器上,我可以使用npm install和npm start运行这个应用程序。
当我试图通过docker-compose up运行它时,我会得到以下错误消息:
Couldn't connect to Docker daemon at http+docker://localunixsocket - is it running?
If it's at a non-standard location, specify the URL with the DOCKER_HOST environment variable我的Dockerfile看起来如下:
FROM node:8.11
WORKDIR /usr/src/app
ARG NODE_ENV
ENV NODE_ENV $NODE_ENV
COPY package.json /usr/src/app/
RUN npm install
COPY . /usr/src/app
# replace this with your application's default port
EXPOSE 8000
CMD [ "npm", "run", "dev" ]而docker-compose.yml看起来是这样的:
version: "2"
services:
web:
build: .
command: nodemon -L --inspect=0.0.0.0:5858
volumes:
- .:/usr/src/app
ports:
- "8000:8000"
- "5858:5858"实际上,应用程序应该运行在localhost:8000或低于localhost:5858的调试模式下。
知道Dockerfile或docker-come.yml有什么问题吗?我已经尝试过这里所描述的修复程序,但这两种建议对我都不起作用,所以肯定有其他错误。
提前谢谢,并致以亲切的问候。
如果你需要更多的代码,请随时告诉我,我把它添加到问题中。
更新: package.json看起来如下:
{
"name": "custom-meta-model",
"version": "0.0.0",
"description": "An bpmn-js modeler extended with a custom meta-model",
"main": "app/index.js",
"scripts": {
"all": "grunt",
"dev": "grunt auto-build"
},
"keywords": [
"bpmnjs-example"
],
"author": {
"name": "Nico Rehwaldt",
"url": "https://github.com/nikku"
},
"contributors": [
{
"name": "bpmn.io contributors",
"url": "https://github.com/bpmn-io"
}
],
"license": "MIT",
"devDependencies": {
"babel-core": "^6.26.3",
"babel-preset-env": "^1.7.0",
"babelify": "^8.0.0",
"grunt": "^1.2.0",
"grunt-browserify": "^5.3.0",
"grunt-contrib-watch": "^1.1.0",
"grunt-contrib-connect": "^2.1.0",
"grunt-contrib-copy": "^1.0.0",
"load-grunt-tasks": "^5.1.0",
"stringify": "^5.2.0"
},
"dependencies": {
"bpmn-js": "^7.2.0",
"diagram-js": "^6.6.1",
"jquery": "^3.5.1"
}
}更新2:现在看起来好多了,我修正了Dockerfile中的Command。现在输出结果告诉我,没有找到“咕噜”。混凝土:
Step 9/9 : CMD [ "npm", "run", "dev" ]
---> Running in f51692a86908
Removing intermediate container f51692a86908
---> 53e88bbb46c4
Successfully built 53e88bbb46c4
Successfully tagged overlayexample2_web:latest
Recreating overlayexample2_web_1
Attaching to overlayexample2_web_1
web_1 |
web_1 | > custom-meta-model@0.0.0 dev /usr/src/app
web_1 | > grunt auto-build
web_1 |
web_1 | sh: 1: grunt: not found
web_1 | npm ERR! code ELIFECYCLE
web_1 | npm ERR! syscall spawn
web_1 | npm ERR! file sh
web_1 | npm ERR! errno ENOENT
web_1 | npm ERR! custom-meta-model@0.0.0 dev: `grunt auto-build`
web_1 | npm ERR! spawn ENOENT
web_1 | npm ERR!
web_1 | npm ERR! Failed at the custom-meta-model@0.0.0 dev script.
web_1 | npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
web_1 | npm WARN Local package.json exists, but node_modules missing, did you mean to install?
web_1 |
web_1 | npm ERR! A complete log of this run can be found in:
web_1 | npm ERR! /root/.npm/_logs/2020-08-21T17_03_50_937Z-debug.log
overlayexample2_web_1 exited with code 1我怎么才能修好它?
也许必须修改Gruntfile.js,目前它看起来如下:
module.exports = function(grunt) {
require('load-grunt-tasks')(grunt);
grunt.loadNpmTasks('grunt-docker');
grunt.initConfig({
browserify: {
options: {
transform: [
[ 'stringify', {
extensions: [ '.bpmn' ]
} ],
[ 'babelify', {
global: true
} ]
]
},
watch: {
options: {
watch: true
},
files: {
'dist/index.js': [ 'app/**/*.js' ]
}
},
app: {
files: {
'dist/index.js': [ 'app/**/*.js' ]
}
}
},
copy: {
diagram_js: {
files: [ {
src: require.resolve('diagram-js/assets/diagram-js.css'),
dest: 'dist/css/diagram-js.css'
} ]
},
app: {
files: [
{
expand: true,
cwd: 'app',
src: ['**/*.*', '!**/*.js'],
dest: 'dist'
}
]
}
},
watch: {
options: {
livereload: false
},
samples: {
files: [ 'app/**/*.*' ],
tasks: [ 'copy:app' ]
},
},
connect: {
livereload: {
options: {
port: 8000,
livereload: true,
hostname: '*',
open: false,
base: [
'dist'
]
}
}
}
});
// tasks
grunt.registerTask('build', [ 'browserify:app', 'copy' ]);
grunt.registerTask('auto-build', [
'copy',
'browserify:watch',
'connect:livereload',
'watch'
]);
grunt.registerTask('default', [ 'build' ]);
};发布于 2020-08-19 20:23:27
您必须启用并启动系统中的Docker守护进程。
如果您在Linux上,试试它:sudo systemctl enable docker && sudo systemctl start docker
如果不能将systemctl识别为命令,则应使用:service docker start。
第一次运行需要systemctl start,因为enable只会在重启后自动启动守护进程。启用它之后,它将在引导时自动启动。
发布于 2020-08-19 20:22:55
您的Docker服务没有运行,您需要手动启动Docker桌面。
发布于 2020-08-19 21:11:02
Dockerfile和docker-compose.file没有什么问题。
试着和sudo一起跑:
sudo docker-compose uphttps://stackoverflow.com/questions/63494379
复制相似问题