无法通过ebcli在本地计算机上运行docker容器

问题描述 投票:0回答:1

ebcli如何发出docker运行命令似乎有些问题。

以下是我在MacOS机器上运行的命令

eb local run --port 3001

虽然eb能够成功构建docker映像,但是当它尝试运行docker映像时,它会在下面抛出错误。

docker: invalid publish opts format (should be name=value but got '3001:${PORT}').

以下是我的Dockerfile的外观

# Check out https://hub.docker.com/_/node to select a new base image
FROM node:10-slim

# Set to a non-root built-in user `node`
USER node

# Create app directory (with user `node`)
RUN mkdir -p /home/node/app

WORKDIR /home/node/app

# Install app dependencies
# A wildcard is used to ensure both package.json AND package-lock.json are copied
# where available (npm@5+)
COPY --chown=node package*.json ./

RUN npm install

# Bundle app source code
COPY --chown=node . .

RUN npm run build

# Bind to all network interfaces so that it can be mapped to the host OS
ENV HOST=0.0.0.0 PORT=3000

EXPOSE ${PORT}

CMD [ "node", "." ]
node.js docker amazon-elastic-beanstalk ebcli
1个回答
0
投票

这是ebcli的限制。发生这种情况的原因是ebcli解析您的dockerfile来检索公开的端口。因为您在EXPOSE指令中引用环境变量,所以ebcli会将其读取为文字字符串,并尝试将端口选项分配给-p 3001:${PORT}

要解决此问题,您将需要修改EXPOSE指令以显式公开值3000。

示例:

EXPOSE 3000

随时在ebcli github repository上报告此。

© www.soinside.com 2019 - 2024. All rights reserved.