Dockerfile:有什么方法可以从.env文件读取变量

I want to read the PORT variable inside Dockerfile which is defined in .env file. Is there any way to do this?

这是我的Dockerfile:

FROM node:11-alpine

RUN mkdir -p /usr/src/app

WORKDIR /usr/src/app

ENV PORT=3000

COPY . .

RUN npm install

EXPOSE 3000

CMD ["npm", "run", "start"]
评论
Peter
Peter

you can use the ARG in your Dockerfile which is meant for this purpose.

点赞
评论