当我尝试访问Docker容器外部时,我收到下面提到的错误的空数据。我对Docker容器中的curl和wget命令没有任何问题。容器基于Angular JS图像。
“localhost没有发送数据.ERR_EMPTY_RESPONSE”和“curl:(52)来自服务器的空回复”
请帮忙。
抱歉!忘了发布实际代码。这是我的Dockerfile和package.json文件。
的package.json
{
"name": "angularjs-project”,
"version": "0.0.0",
"license": "MIT",
"scripts": {
"ng": "ng",
"start": "ng serve -H 0.0.0.0",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
"private": true,
"dependencies": {
"@angular/animations": "^4.3.6",
"@angular/common": "^4.2.4",
"@angular/compiler": "^4.2.4",
"@angular/core": "^4.2.4",
"@angular/forms": "^4.2.4",
"@angular/http": "^4.2.4",
"@angular/platform-browser": "^4.2.4",
"@angular/platform-browser-dynamic": "^4.2.4",
"@angular/router": "^4.2.4",
"core-js": "^2.4.1",
"font-awesome": "^4.7.0",
"primeng": "^4.1.3",
"rxjs": "^5.4.2",
"zone.js": "^0.8.14"
},
"devDependencies": {
"@angular/cli": "1.3.2",
"@angular/compiler-cli": "^4.2.4",
"@angular/language-service": "^4.2.4",
"@types/jasmine": "~2.5.53",
"@types/jasminewd2": "~2.0.2",
"@types/node": "~6.0.60",
"codelyzer": "~3.1.1",
"jasmine-core": "~2.6.2",
"jasmine-spec-reporter": "~4.1.0",
"karma": "~1.7.0",
"karma-chrome-launcher": "~2.1.1",
"karma-cli": "~1.0.1",
"karma-coverage-istanbul-reporter": "^1.2.1",
"karma-jasmine": "~1.1.0",
"karma-jasmine-html-reporter": "^0.2.2",
"protractor": "~5.1.2",
"ts-node": "~3.2.0",
"tslint": "~5.3.2",
"typescript": "~2.3.3"
}
}
Dockerfile
FROM node:6
RUN mkdir -p /angularjs-sample
ADD . /angularjs-sample
WORKDIR /angularjs-sample
RUN cd /angularjs-sample
RUN npm cache clean
RUN npm install -g @angular/cli
RUN npm install
RUN npm update
EXPOSE 4200
CMD ["ng", "serve"]
答案 0 :(得分:1)
CMD ["ng", "serve", "--host=0.0.0.0"]
答案 1 :(得分:0)
这样做的理想方法我建议在创建时将主机IP地址绑定到容器。您不应该从docker文件启动应用程序的运行。创建容器,与主机绑定并编写脚本以启动应用程序
你可以这样做,
ui <- function(id) {
fluidPage(
title = "Job Tracker",
fluidRow(
column(width=6,
selectInput("pickvalue", label = "Pick a Value", choices = unique(iris$Species))
)
),
br(),
fluidRow(
column(12,
DT::dataTableOutput("job_data")
)
),
br(),
fluidRow(
column(12,DT::dataTableOutput("x4"))
)
)
}
server <- function(input, output, session)
{
output$job_data <- DT::renderDataTable({
datatable(iris[iris$Species==input$pickvalue,],selection = "single")
})
output$x4 <- DT::renderDataTable({
s <- input$job_data_rows_selected
datatable(iris[s,])
})
}
“ 8553 ”可以是您的应用程序默认内部端口,其中包含“ 4545 ”外部端口