Docker暴露端口 - OCI运行时创建失败

时间:2018-01-19 17:17:23

标签: node.js express docker dockerfile

Dockerfile

FROM node:9.4
WORKDIR /app
COPY package.json /app
COPY . /app
CMD node app.js
EXPOSE 80

节点/快速代码

var socket_number = 80
var express = require('express');
var app = express();
....
var http = require('http').Server(app);
var io = require('socket.io')(http);
http.listen(socket_number);

生成

C:\Users\john_\Documents\GitHub\purple_cloud>docker run 171b2830a121 -p 3000:80
docker: Error response from daemon: OCI runtime create failed: container_linux.go:296: starting container process caused “exec: “-p”: executable file not found in $PATH”: unknown.

问题

我做错了什么?

观察

docker run 171b2830a121没有" -p 3000:80"不会产生错误,但无法访问端口80或3000。

  

节点app.js ...正常工作

1 个答案:

答案 0 :(得分:4)

您需要重新安排docker run的参数。假设您的图片名称为171b2830a121,则应为:

docker run -p 3000:80 171b2830a121