Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to change the environment variables in docker run command #401

Open
Tiramisupxl opened this issue Jan 12, 2022 · 0 comments
Open

how to change the environment variables in docker run command #401

Tiramisupxl opened this issue Jan 12, 2022 · 0 comments

Comments

@Tiramisupxl
Copy link

I have add the config.js file

var convict = require('convict');

convict.addFormat(require('convict-format-with-validator').ipaddress);

// Define a schema
const config = convict({
  env: {
    doc: 'The application environment.',
    format: ['production', 'development', 'test'],
    default: 'development',
    env: 'NODE_ENV'
  },
  ip: {
    doc: 'The IP address to bind.',
    format: 'ipaddress',
    default: '127.0.0.1',
    env: 'IP_ADDRESS',
    arg: 'host'
  },
  port: {
    doc: 'The port to bind.',
    format: 'port',
    default: 1234,
    env: 'PORT',
    arg: 'port'
  },
  redis: {
    db: {
      doc: 'Redis DB',
      format: Number,
      default: 0,
      env: 'REDIS_DB',
    },
    host: {
      doc: 'Redis Host',
      format: String,
      default: 'localhost',
      env: 'REDIS_HOST',
    },
    password: {
      doc: 'Redis Password',
      format: String,
      default: '',
      env: 'REDIS_PASSWORD',
    },
    port: {
      doc: 'Redis Port',
      format: Number,
      default: 6379,
      env: 'REDIS_PORT',
    },
  },
})


// Perform validation
config.validate({allowed: 'strict'});

module.exports = config;

and the project will be run in docker

when I run

docker run -it -p 30112:30112 -e REDIS_PORT=30012 xx-nodejs

the project still run with the REDIS_PORT equals 6379

Is there some steps I miss?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant