【问题标题】:Select Node variables LISTEN and SERVER through a docker image通过 docker 镜像选择节点变量 LISTEN 和 SERVER
【发布时间】:2015-07-17 16:22:06
【问题描述】:

我需要使用这个命令来执行我的 Node.js 服务器

node server.js LISTEN="0.0.0.0" SERVER="server.com" PORT=3000

但是我的服务器在 CoreOS 集群中,我使用 Docker 来使用容器,但我不知道如何在 Dockerfile 中选择这些变量。

我设置了这个

CMD [/usr/bin/nodejs /src/server.js LISTEN='0.0.0.0' SERVER='piggate.com'"]

但是当我启动服务器时出现错误

【问题讨论】:

    标签: node.js docker coreos


    【解决方案1】:

    Nodejs 环境变量应该在 node 命令之前。

    尝试以下方法之一:

    CMD LISTEN=0.0.0.0 SERVER=piggate.com /usr/bin/nodejs /src/server.js

    ENV LISTEN=0.0.0.0 SERVER=piggate.com CMD /usr/bin/nodejs /src/server.js

    【讨论】:

    • AFAIK 你不能这样设置多个变量(在你的ENV 行),你需要使用<key>=<value> 格式(ENV LISTEN=0.0.0.0 SERVER=piggate.com
    猜你喜欢
    • 2023-01-14
    • 1970-01-01
    • 2018-02-04
    • 2016-02-06
    • 2023-03-09
    • 1970-01-01
    • 2022-06-13
    • 2023-03-03
    • 1970-01-01
    相关资源
    最近更新 更多