基于映像构建Docker卷

编程入门 行业动态 更新时间:2024-10-11 15:20:47
本文介绍了基于映像构建Docker卷的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我试图通过bash命令直接从JS映像构建docker卷。

Im trying to build a docker volume directly from a JS image through a bash command.

这里的困难主要是因为我希望卷的内容等于字符串。

The difficulty here mostly lays on the fact that I want the contents of the volume to be the eval of a string.

字符串本身就是从Kafka流中读取的JS代码。

The string itself is JS code that reads from a Kafka stream.

我知道如何直接从js文件执行bash命令,但是对于命令的外观,我有点迷失了:

I know how to execute the bash command directly from a js file, However im a bit lost when it comes to what the command should look like:

要澄清:-我想指定eval(string)作为要在容器中运行的代码-我想指定三个环境文件-我想直接从js文件运行所有内容。 -这个JS文件已经被docker化,以防万一。

TO clarify: - I want to specify the eval(string) as the code to run inside the container - I want to specify three environment files - I want to run everything directly from a js file . - This JS file is already dockerised in case it matters

我知道堆栈溢出并不意味着给我答案,但是我一直在寻找所有人,弄清楚如何进行是一个真正的困难。因此,任何指针将不胜感激

I understand Stack overflow is not meant to give me answers, but I have looked everyone and im having a real hard time figuring out how to proceed. SO any pointers would be very appreciated

推荐答案

我不确定您是否真的需要对JS文件进行泊坞处理。相反,您可以做的是将传入流(即JS)写入另一个文件,例如volume-creator.js,然后调用该文件。

I am not sure if you really need to dockerize the JS file. Rather what you can do is write the incoming stream (which is JS) to another file e.g. volume-creator.js and then call that file.

在这种情况下,您的volume-creator.js还应包含诸如node-docker之类的依赖项,这将使您的docker命令更容易

In this case your volume-creator.js should also include dependencies like node-docker which will make your docker commands easy and OS agnostic.

我避免对调用方JS进行泊坞的原因是,您可能需要一些额外的特权才能在容器内运行docker命令,例如,可能需要挂载docker可以使您的主机OS和docker系统易受攻击的套接字。

The reason I would avoid dockerizing the invoker JS is you may need some extra privileges to run docker commands within the container e.g you may need to mount the docker socket which can make your host OS and docker system vulnerable .

更多推荐

基于映像构建Docker卷

本文发布于:2023-10-27 04:28:18,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1532315.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:映像   Docker

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!