基于映像构建Docker卷 [英] Build a docker volume based of an image

查看:103
本文介绍了基于映像构建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卷的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆