从昨天开始,我一直试图使用名为"dockerode“的node.js库为”文件夹“文件夹中的每个容器创建一个单独的文件夹。不幸的是,我没有找到任何有效的解决方案。我查看了Pterodactyl (旧的)源代码,其中有它,但不幸的是,它也不适用于我。你知道有什么好的解决办法能奏效吗?
如果你需要更多的信息,我会写在这里给你。
祝你今天休息愉快,多米
发布于 2022-01-10 21:52:12
您只想创建一个临时文件夹吗?如果是这样,您只需使用fs模块:
const fs = require('fs');
exports.createTmpDir = (dir) => {
if (!fs.existsSync(dir)) {
fs.mkdirSync(dir, { recursive: true });
}
};
exports.generateRandomString = (length = 15) => {
return Math.random().toString(36).substring(2, length);
};你可以这样使用它:
// assume you call it from the root project directory
const root = ${process.cwd()}`;
// create a temp folder path. use this if you want to clean up later.
const tempDir = `${root}/tmp/${generateRandomString()}`;
createTmpDir(tempDir);您还可以使用fs将您的dockerfile复制或移动到该文件夹中。
不确定这是否回答了你的问题?
https://stackoverflow.com/questions/66221044
复制相似问题