Reputation: 1723
I'm trying to dockerize a basic nodejs app. My dockerfile is the follow
FROM node:10
WORKDIR /usr/src/app
COPY package*.json ./
RUN npm install
COPY . .
EXPOSE 80
CMD [ "node", "index.js" ]
After i build the image I'm trying to running it with
docker run -p 3000:3000 imagename -e connectionString=myConnString
But I received always the same error
[eval]:1
connectionString=myConnString
ReferenceError: myConnString is not defined
How can I solve?
Upvotes: 3
Views: 774
Reputation: 4150
The docker run
syntax is docker run [OPTIONS] IMAGE[:TAG|@DIGEST] [COMMAND] [ARG...]
, anything passed after the IMAGE[:TAG|@DIGEST]
is passed as [COMMAND] [ARG...]
.
The environment variable setting should be passed in the run [OPTIONS]
i.e.: docker run -p 3000:3000 -e connectionString=myConnString imagename
Upvotes: 4
Reputation: 12278
Your docker run command should be:
docker run -p 3000:3000 -e connectionString=myConnString imagename
-e
option should be before imagename
.
Give it a try.
Upvotes: 1