{"id":127651,"date":"2018-11-18T09:33:28","date_gmt":"2018-11-18T01:33:28","guid":{"rendered":"https:\/\/lrxjmw.cn\/?p=127651"},"modified":"2018-11-12T09:34:21","modified_gmt":"2018-11-12T01:34:21","slug":"docker-jdocker","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/docker-jdocker.html","title":{"rendered":"\u57fa\u4e8eDocker\u5c01\u88c5\u7684\u5f00\u53d1\u5305\u5de5\u5177"},"content":{"rendered":"

\u57fa\u4e8e Docker1.12+ (Docker API 1.24+) \u5f00\u53d1\u51fa\u7684\u5f00\u53d1\u5305\uff0c\u901a\u8fc7\u5c01\u88c5 Docker API \u4f7f\u5f00\u53d1\u8005\u53ef\u4ee5\u5feb\u901f\u7684\u4f7f\u7528 Java \u5f00\u53d1\u51fa\u63a7\u5236\u548c\u64cd\u4f5c Docker \u7684\u5e94\u7528\uff0c\u4f7f\u7528\u6d41\u5f0f\u64cd\u4f5c,\u7b80\u5355\u660e\u4e86\u3002<\/p>\n

\u4e3a Javaer \u7684\u5c0f\u4f19\u4f34\u4eec\u63d0\u4f9b\u65b9\u4fbf\u76f4\u63a5\u7684\u64cd\u4f5c Docker \u7684\u65b9\u5f0f.<\/p>\n

\u5b8c\u5584\u7684\u6d4b\u8bd5\u7528\u4f8b\u8986\u76d6\u7387\u8fbe87%\u3002<\/p>\n

JDocker \u662f Voovan \u5f00\u6e90\u9879\u76ee\u7684\u4e00\u4e2a\u5b50\u9879\u76ee,\u81ea\u7136\u662f\u4f9d\u8d56\u4e8e voovan\u5f00 \u6e90\u9879\u76ee\u7684\u3002<\/p>\n

\"\"<\/p>\n

\u5bf9 Voovan \u9879\u76ee\u7684 Maven \u4f9d\u8d56:org.voovanvoovan-framework1.0-beta-*,\u901a\u8fc7\u8bbe\u7f6eorg.voovan.docker.DockerGlobal\u4e2d\u7684\u73af\u5883\u53d8\u91cf\u6765\u8fde\u63a5\u81f3 Docker\u3002<\/p>\n

\r\npublic static String DOCKER_REST_HOST = \"127.0.0.1\";\r\n    public static int DOCKER_REST_PORT = 2735;\r\n    public static String DOCKER_REST_CHARSET = \"UTF-8\";\r\n    public static int DOCKER_REST_TIMEOUT = 5;\r\n    public static boolean DEBUG = false;\r\n<\/pre>\n

\u4f7f\u7528 JDocker \u521b\u5efa\u4e00\u4e2a\u5bb9\u5668:<\/p>\n

\r\n\/\/\u6784\u9020\u4e00\u4e2a\u521b\u5efa\u547d\u4ee4\r\n        CmdContainerCreate createCmd =  CmdContainerCreate.newInstance(\"d_test\");\r\n        \/\/\u4f7f\u7528\u6d41\u5f0f\u64cd\u4f5c\u6765\u521b\u5efa\u5bb9\u5668\r\n        Object data = createCmd.image(\"alpine\").network(\"bridge\")\r\n                .volume(\"v_tx:\/v_tx\").link(\"dockerfly:dockerfly\")\r\n                .cmd(\"ping\",\"127.0.0.1\").env(\"author=helyho\")\r\n                .exposePort(22,\"tcp\",\"2222\").send();\r\n        createCmd.close();\r\n        Logger.info(formatJSON(data));\r\n\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"

\u57fa\u4e8e Docker1.12+ (Docker API 1.24+) \u5f00\u53d1\u51fa\u7684\u5f00\u53d1\u5305\uff0c\u901a\u8fc7\u5c01\u88c5 Docker A […]<\/p>\n","protected":false},"author":668,"featured_media":6236,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[55],"tags":[],"class_list":["post-127651","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-thread"],"acf":[],"_links":{"self":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/127651","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/users\/668"}],"replies":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/comments?post=127651"}],"version-history":[{"count":4,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/127651\/revisions"}],"predecessor-version":[{"id":127798,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/127651\/revisions\/127798"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media\/6236"}],"wp:attachment":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media?parent=127651"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/categories?post=127651"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/tags?post=127651"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}