How to use docker with volume and device as an action in the Openwhisk

时间:2017-06-15 10:28:24

标签: docker openwhisk

I have some code in docker which polls a directory to do some action upon it. This directory is passed using -v option while running docker there are also some devices that are used like --device /dev/nvidia0:/dev/nvidia0 --device /dev/nvidiactl:/dev/nvidiactl

in the wsk docker action i see that to create a docker action i use the command as below wsk -i action create --docker

i wanted to understand how to pass the volume and device info to the docker as the starting and stopping of this docker will be maintained by openwhisk. Or is there some other workaround for this

2 个答案:

答案 0 :(得分:1)

OpenWhisk不支持使用附加卷运行基于Docker的操作。用户无法控制存储设备。

解决方法是使用对象库作为存储位置。然后,OpenWhisk Action可以使用API​​从无服务器运行时查询,检索和修改数据。

答案 1 :(得分:0)

老问题,但我留言,对于本地测试部署,我使用已安装的NFS网络文件系统和本地路径运行OpenWhisk。为此,我只是简单地将挂载添加到源(硬编码,可以进行ENV设置,下一步):

在此处添加卷装入-v: 文件:core / invoker / src / main / scala / whisk / core / containerpool / docker / DockerContainer.scala

    val args = Seq(
    "--cpu-shares",
    cpuShares.toString,
    "--memory",
    s"${memory.toMB}m",
    "--memory-swap",
    s"${memory.toMB}m",
    "--network",
    network,
    "-v",
    "/mnt/nfs:/mnt/nfs",
    "-v",
    "/mnt/data:/mnt/data") ++
    environmentArgs ++
    dnsServers.flatMap(d => Seq("--dns", d)) ++
    name.map(n => Seq("--name", n)).getOrElse(Seq.empty) ++
    params

要构建它,然后在openwhisk-master目录中运行:

./gradlew distdocker 

标记生成的调用程序容器,以便在堆栈中使用它:

docker tag whisk/invoker openwhisk/invoker

重新启动后,您就拥有了自己的音量。

但是注意:这与无状态微服务的设计原则相矛盾,可能不是最明智的方法。重新检查是否可以不安装卷(它们不是无状态)。

相关问题