尝试构建docker镜像时出错:无法拨打gRPC:无法升级到h2c,收到500

jsc*_*ten 11 docker grpc

当我尝试执行时docker build -t exampledockeracc/testapp:v1.0.0 .我收到以下错误:failed to dial gRPC: unable to upgrade to h2c, received 500, context canceled

当我搜索错误时,人们提出了重新启动 docker 并在执行前等待一段时间的解决方案,但它似乎不起作用。

我读过一些有关 dockerfile 中指定的目标操作系统与计算机上当前运行的容器操作系统之间操作系统不匹配的内容。我正在使用Windows。

这是我的 dockerfile:

#############
### build ###
#############

# base image
FROM node:12.2.0 as build

# install chrome for protractor tests
RUN wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add -
RUN sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list'
RUN apt-get update && apt-get install -yq google-chrome-stable

# set working directory
WORKDIR /app

# add `/app/node_modules/.bin` to $PATH
ENV PATH /app/node_modules/.bin:$PATH

# install and cache app dependencies
COPY ./package.json /app/package.json
RUN npm install
RUN npm install -g @angular/cli@9.0.0

# add app
COPY . /app

# run tests
# RUN ng test --watch=false
# RUN ng e2e --port 4202

# generate build
RUN ng build --output-path=dist --prod="true"

############
### prod ###
############

# base image
FROM nginx:alpine

# copy artifact build from the 'build environment'
COPY --from=build /app/dist /usr/share/nginx/html
COPY --from=build /app/nginx.conf /etc/nginx/conf.d/default.conf

# expose port 80
EXPOSE 80

# run nginx
CMD ["nginx", "-g", "daemon off;"]
Run Code Online (Sandbox Code Playgroud)

它用于 Angular 应用程序。

Kam*_*san 8

这个问题是因为你没有让Docker有足够的时间来完全加载。请等待一段时间,然后重试。

另一个原因是操作系统不匹配。节点映像基于 Linux,而您使用的是 Windows。我建议您购买 Linux 服务器或虚拟机来构建容器。