Javascript 在Docker容器中运行JS脚本时出现意外错误

Javascript 在Docker容器中运行JS脚本时出现意外错误,javascript,node.js,docker,Javascript,Node.js,Docker,因此,当我在Windows终端上运行脚本时,一切正常。我使用的所有LIB都是Linux支持的,但是当我制作Docker映像并运行它时,我会得到一个错误,而这个错误不会发生在我的vanilla终端上 TypeError [ERR_INVALID_ARG_TYPE]: The "key" argument must be of type string or an instance of Buffer, TypedArray, DataView, or KeyObject. Rec

因此,当我在Windows终端上运行脚本时,一切正常。我使用的所有LIB都是Linux支持的,但是当我制作Docker映像并运行它时,我会得到一个错误,而这个错误不会发生在我的vanilla终端上

TypeError [ERR_INVALID_ARG_TYPE]: The "key" argument must be of type string or an instance of Buffer, TypedArray, DataView, or KeyObject. Received undefined

at prepareSecretKey (internal/crypto/keys.js:322:11)

at new Hmac (internal/crypto/hash.js:113:9)

at Object.createHmac (crypto.js:147:10)

at verifyPostData (/usr/src/app/bin/utils/utilFunctions.js:85:35)

at Layer.handle [as handle_request] (/usr/src/app/node_modules/express/lib/router/layer.js:95:5)

at next (/usr/src/app/node_modules/express/lib/router/route.js:137:13)

at Route.dispatch (/usr/src/app/node_modules/express/lib/router/route.js:112:3)

at Layer.handle [as handle_request] (/usr/src/app/node_modules/express/lib/router/layer.js:95:5)

at /usr/src/app/node_modules/express/lib/router/index.js:281:22

at Function.process_params (/usr/src/app/node_modules/express/lib/router/index.js:335:12)
当我的脚本验证收到的负载时,就会发生这种情况。你知道会发生什么吗

其中定义了密钥:

const sig=req.get('X-Hub-Signature')||“”;
const hmac=crypto.createHmac('sha1',process.env.SECRET!);
const digest=Buffer.from(
'sha1='+hmac.update(payload.digest('hex'),
“utf8”
);
常量校验和=Buffer.from(sig,'utf8');
}

您的
密钥定义在哪里?更新的post@milanmarkovic您的env变量机密可能在containerOh中不可用。我会调查的。