1

I'm trying to Dockerize a Node.js app and, while creating the Dockerfile, i came across the problem that the credetials for connecting to the database are stored in a .txt file. How can i set the content from that .txt file as an ENV variable in my Dockerfile?

  • write a shell script that extracts those credentials and writes some lines in the Dockerfile such as `ENV mypassword abc123`? – user2915097 Jul 11 '17 at 08:32

1 Answers1

4

You can use the --env-file command line option:

docker run --env-file ./env.list ubuntu bash

This file should use the syntax <variable>=value (which sets the variable to the given value) or <variable> (which takes the value from the local environment), and # for comments.

For more details, see the documentation here.

ck1
  • 5,243
  • 1
  • 21
  • 25