Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/40.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Node.js Deno:写入Docker容器上的CSV文件(权限被拒绝(操作系统错误13))_Node.js_Docker_Deno - Fatal编程技术网

Node.js Deno:写入Docker容器上的CSV文件(权限被拒绝(操作系统错误13))

Node.js Deno:写入Docker容器上的CSV文件(权限被拒绝(操作系统错误13)),node.js,docker,deno,Node.js,Docker,Deno,我正在学习Deno的技巧,并且在使用DenowriteCSV()实用程序写入CSV文件时遇到了权限问题。我已经准备好了这个项目,让它在顶级码头工人身上运行 Dockerfile CMD[“run”、“--allow read”、“--allow run”、“--allow write”、“--allow net”、“main.ts”] 梅因酒店 import { serve, readCSV, writeCSV } from "./deps.ts"; const URL = "https:/

我正在学习Deno的技巧,并且在使用DenowriteCSV()实用程序写入CSV文件时遇到了权限问题。我已经准备好了这个项目,让它在顶级码头工人身上运行

Dockerfile

CMD[“run”、“--allow read”、“--allow run”、“--allow write”、“--allow net”、“main.ts”]

梅因酒店


import { serve, readCSV, writeCSV } from "./deps.ts";

const URL = "https://www.getcats.com/api"
const DEFAULT_PRODUCT_ID = "xxxxxxxxxxxx";
const DEFAULT_DESCRIPTION = "Description";
const options = {
  method: "POST",
  url: URL,
  body: {},
  headers: {
    "x-api-key": "xxxxxxxxxxxxx"
  },
  json: true // Automatically stringifies the body to JSON
};

// CSV File Properties
const f = await Deno.open("./inbound/example.csv");
const outputFile = await Deno.open("./outbound/outbound.csv", { write: true, create: true, read: true, truncate: true });

for await (const row of readCSV(f)) {
  for await (const cell of row) {
    queueMicrotask(async () => {

      const response = await fetch(URL, {
        method: "POST",
        headers: {
          'content-type': 'application/json',
          "x-api-key": "xxxxxxxxxxxxxxx"
        },
        body: JSON.stringify({
          memberId: cell,
          productId: DEFAULT_PRODUCT_ID,
          description: DEFAULT_DESCRIPTION
        }),
      });

      response.json()
        .then(async (res)=> {
          const data = res.data;
          const memberId = data.memberId;
          const hashId = data.id;
          const rows = [memberId, hashId]
          console.log(`CAT ID: ${memberId} - HASH ID: ${hashId}`);                

          await writeCSV(outputFile, rows);
          outputFile.close();

        })

    })

  }
}
f.close();


我假设在运行容器时通过发送
---allow write
可以解决此烫发问题。还有谁在Deno over Docker中的目录中有问题吗?

你能从博客中查看类似问题的解决方案建议吗

以下是简单的问题描述:

我遇到的一件事是,最初Dockerfile指定了 具有有限权限的用户。这引发了一个非常神秘的异常:

这里有一个解决方案:

事实证明,这是因为我们希望在
端口80
<代码>非特权用户(非root)
无法打开侦听套接字
在1024以下的端口上
。确保 运行进程的用户(可在
你的Dockerfile
有足够的权限
。在我们的例子中,只需省略
USER
工作正常


这里还有一个样品

你能从博客上查看类似问题的解决方案建议吗

以下是简单的问题描述:

我遇到的一件事是,最初Dockerfile指定了 具有有限权限的用户。这引发了一个非常神秘的异常:

这里有一个解决方案:

事实证明,这是因为我们希望在
端口80
<代码>非特权用户(非root)
无法打开侦听套接字
在1024以下的端口上
。确保 运行进程的用户(可在
你的Dockerfile
有足够的权限
。在我们的例子中,只需省略
USER
工作正常


这里还有一个样品

如果使用-A开关来代替所有这些开关,会发生什么情况?您使用的是什么版本的Deno?-运行:Deno 1.0.0,v8 8.4.300,typescript 3.9.2-我尝试使用-A命令运行它,但没有luck@victorpalma显示您的
deps.ts
文件,我需要查看依赖项“德诺·兰德/std@0.50.0/http/server.ts;从“deno.land/x/csv/mod.ts”导出{readCSV,writeCSV}";如果使用-A开关来代替所有这些开关,会发生什么情况?您使用的是什么版本的Deno?-运行:Deno 1.0.0,v8 8.4.300,typescript 3.9.2-我尝试使用-A命令运行它,但没有luck@victorpalma显示您的
deps.ts
文件,我需要查看依赖项“德诺·兰德/std@0.50.0/http/server.ts“从”deno.land/x/csv/mod.ts“导出{readCSV,writeCSV}”;是的,这不是问题。deno告诉我以下行失败:const outputFile=wait deno.open(“./outbound/outbound.csv”,{write:true,create:true,read:true,truncate:true});是的,这不是问题所在。Deno告诉我以下行失败:const outputFile=wait Deno.open(“./outbound/outbound.csv”,{write:true,create:true,read:true,truncate:true});
error: Uncaught PermissionDenied: Permission denied (os error 13)
    at unwrapResponse ($deno$/ops/dispatch_json.ts:43:11)
    at Object.sendSync ($deno$/ops/dispatch_json.ts:72:10)
    at Object.listen ($deno$/ops/net.ts:51:10)
    at listen ($deno$/net.ts:152:22)
    at serve (https://deno.land/std@0.50.0/http/server.ts:261:20)
    at file:///app/main.ts:4:11