java - 如何为基于 json 的插件设置 'docker plugin install'

标签 java spring docker

我正在开发一个全新的卷插件,我需要所有 vol-test要通过的测试。我已经成功通过了所有测试(在安装了插件的环境中),除了第一个测试,即 docker plugin install 。问题是有three安装自定义插件的可能方法:

.sock files are UNIX domain sockets.
.spec files are text files containing a URL, such as unix:///other.sock or tcp://localhost:8080.
.json files are text files containing a full json specification for the plugin.

我们使用json,它只是一个实现docker API的REST服务器(用java、spring编写)。安装过程非常简单:只需复制 /etc/docker/plugins 中的 json 文件,dockerd 就会自动发现它。
当我尝试将插件集成到 docker plugin install 命令时,问题就出现了。正如它所说的here :

Docker looks first for the plugin on your Docker host. If the plugin does not exist locally, then the plugin is pulled from the registry.

我们的安装过程不假设连接到私有(private)或公共(public)注册表,因此我们首先需要 docker plugin create 命令才能在本地创建插件。这就是我很难思考如何使用基于 json 的插件来做到这一点的地方。根据this doc,我需要指定插件的路径。如果我使用目录名称,则期望目录中存在 config.json 和 rootfs 。

但是
1. config.json - 这是一个配置,描述了 .sock 格式的配置,而不是 .json 格式(如果我错了)
2. 如何创建 rootfs?如果我的插件只是一个独立的 REST 服务并且它甚至不在容器中,为什么需要它?

感谢任何帮助。

最佳答案

config.json - this is a config, that describes .sock format configs, and not the .json format (please correct me if I'm wrong)

我已经验证了它可以与 .spec 文件一起使用,但不太确定它如何与 json 文件一起使用。对于 .spec 文件,您不会在 config.json 中提及 .spec 文件。这仅用于 unix 套接字插件(选项 1)。事实上,TCP 套接字插件不需要 config.json。

how do I create the rootfs and why do I need it if my plugin is just a standalone REST service and it is not even in the container?

据我了解,rootfs仅适用于unix套接字插件。如果 .spec 文件存在于正确的文件夹中,则插件发现可以开箱即用。简而言之,您只需创建规范文件并将其放入正确的发现文件夹中,然后尝试使用该插件名称引导容器。您不必运行“docker plugin create/install/enable”之类的命令。您运行服务器,将文件放在正确的文件夹中,然后让新容器使用该插件。

关于java - 如何为基于 json 的插件设置 'docker plugin install',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58549130/

相关文章:

java - Spring 添加监听器作为组件而不是通过构造函数

spring - 向多个 RabbitMQ 消费者提供相同的消息

java - 从 Katalon 的 Groovy/Java 测试用例运行外部程序

java - 如何最好地编写以下代码?可行吗?请看说明

java - 如何查找包含非单词字符的字符串?

java - 编写带有多个内连接和其他条件的 Spring 规范

java - Spring 4 + Hibernate 5 = org.springframework.orm.jpa.EntityManagerHolder 无法转换为 org.springframework.orm.hibernate5.SessionHolder

postgresql - 在 Postgres Docker 镜像中进行 Sequelize

ruby-on-rails - Docker 容器无法填充 Rails 应用程序的 SECRET_TOKEN 环境变量

docker - 阻止从 Docker 容器到私有(private) IP 的传出连接