I'm unable to pass my arguments from docker-compose.yml into build
docker-compose.yml
version: '2'
services:
mail_prod:
#env_file:
# - .env
build:
context: ./server
dockerfile: ./Dockerfile
args:
- FROM_VERIFIED_EMAIL=sadasd
- HOST_SMTP=asdasd
- PORT_SMTP=asdasdsad
- NAME_SMTP=asdasd
- PASS_SMTP=iasdasdasd
- AUTH_TOKEN_MAILSEND=asdasdasdasd
ports:
- 8080:8080
restart: always
Dockerfile:
FROM node:12
# Create app directory
WORKDIR /usr/src/app
ARG HOST_SMTP
ARG PORT_SMTP
ARG NAME_SMTP
ARG PASS_SMTP
ARG AUTH_TOKEN_MAILSEND
ARG FROM_VERIFIED_EMAIL
# Install app dependencies
# A wildcard is used to ensure both package.json AND package-lock.json are copied
# where available (npm@5+)
COPY package*.json ./
RUN npm install
# If you are building your code for production
# RUN npm ci --only=production
# Bundle app source
COPY . .
EXPOSE 8080
CMD node server.js $HOST_SMTP $PORT_SMTP $NAME_SMTP $PASS_SMTP $AUTH_TOKEN_MAILSEND $FROM_VERIFIED_EMAIL
server.js
'use strict'
// Print the arguments which are passed
var myArgs = process.argv.slice(2);
console.log('myArgs: ', myArgs);
This is what I get in output when I run the container:
mail_prod_1 | myArgs: []
Where am i going wrong?
question from:
https://stackoverflow.com/questions/65516811/dockerfile-doesnt-get-the-arguments-passed-from-docker-compose 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…