3

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?

2
  • 2
    The -e connectionString=myConnString should be passed in the docker run i.e. docker run -p 3000:3000 -e connectionString=myConnString imagename - anything passed after the image:tag is passed as [COMMAND] [ARG...] to the ENTRYPOINT (if any) ref. the doc. Commented Aug 31, 2019 at 14:37
  • 1
    great it seems this was my mistake! Commented Aug 31, 2019 at 14:40

2 Answers 2

4

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

Sign up to request clarification or add additional context in comments.

Comments

1

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.