【发布时间】:2019-11-06 21:23:23
【问题描述】:
我是 Docker 的超级新手,最近将一个项目从 App Engine 转移到 Cloud Run。很容易,喜欢它。
不过,现在我正在尝试更新图像(因为我添加了一些新代码)。我知道我需要进入一个实际的容器来更新图像(我想?)但是当我尝试docker run 时,我收到了unexpected operator 错误。
这让我非常生气。
我无法启动容器。我无法编辑我的图像。我无法在 Cloud Run 上上传新版本。
据我所知,unexpected operator 错误必须处理 Dockerfile。因此,这是我的 Dockerfile(由 Google 提供,用于在 Cloud Run 上部署映像)。
Dockerfile
#Use the official Node.js 10 image
#https://hub.docker.com/_/node
FROM node:10
#Create and change to the app directory
WORKDIR /usr/src/app
#Copy application dependency manifests to the container image.
#A wild card is used to ensure both package.json AND package-lock.json are copied.
#Copying this separately prevents re0running npm install on every code change.
COPY *package.json ./
#Install production dependences
RUN npm install --only=production
#COPY local code to the container image
COPY . .
#Run the web service on container startup
CMD [ "npm", "start" ]
我得到的具体unexpected operator 错误是/bin/sh: 1: [: npm.: unexpected operator
老实说,我现在不知道该怎么办。我想我需要第二双眼睛才能仔细查看。
【问题讨论】:
-
如果你运行
docker run container_name npm --version会发生什么? -
我收到
6.9.0作为回复 -
那么您的 npm 安装工作正常...请运行此
docker run container_name npm start -
运行也很好。我收到了我应该收到的
App listening to pop 8080回复 -
你必须通过运行
docker build --tag="nmp_app:latest" -f Dockerfile .来重建Docker文件
标签: node.js docker google-cloud-run