{"id":141,"date":"2023-12-21T11:38:38","date_gmt":"2023-12-21T03:38:38","guid":{"rendered":"https:\/\/my.oindalvi.eu.org\/?p=141"},"modified":"2023-12-21T11:38:38","modified_gmt":"2023-12-21T03:38:38","slug":"%e7%94%9f%e6%88%90oracle%e5%ae%a2%e6%88%b7%e7%ab%afdocker%e9%95%9c%e5%83%8f%e7%9a%84%e4%b8%a4%e7%a7%8d%e7%8e%a9%e6%b3%95","status":"publish","type":"post","link":"https:\/\/my.di.cloudns.asia\/index.php\/2023\/12\/21\/141.html","title":{"rendered":"\u751f\u6210oracle\u5ba2\u6237\u7aefdocker\u955c\u50cf\u7684\u4e24\u79cd\u73a9\u6cd5"},"content":{"rendered":"<div class=\"post-content-area\">\n<div class=\"post-header font-alt\">\n<h2 class=\"post-title\">\u751f\u6210oracle\u5ba2\u6237\u7aefdocker\u955c\u50cf\u7684\u4e24\u79cd\u73a9\u6cd5<\/h2>\n<div class=\"post-meta\">\n                                        <span><i class=\"fa fa-user\"><\/i> By <a href=\"https:\/\/www.yinyubo.com\/?author=1\">\u674e\u9547\u4f1f<\/a><\/span><br \/>\n                                        <span><i class=\"fa fa-calendar\"><\/i>  <a href=\"https:\/\/www.yinyubo.com\/?p=1228\">2022\u5e7411\u670816\u65e5<\/a><\/span>\n                                    <\/div>\n<\/p><\/div>\n<div class=\"post-entry\">\n<h2 class=\"wp-block-heading\">\u80cc\u666f<\/h2>\n<p>\u6211\u4eec\u7684oracle\u670d\u52a1\u7aef\u662foracle12g\u7248\u672c\uff0c\u5e94\u7528\u7a0b\u5e8f\u5747\u7531golang\u6216\u8005python\u7f16\u5199\uff0c\u8fd0\u884c\u5728k8s \u5bb9\u5668\u91cc\uff0c\u90a3\u6211\u4eec\u5c31\u9700\u8981build\u4e00\u4e9bdocker\u5bb9\u5668\u6765\uff0c\u90a3\u5982\u4f55build\u5462\uff1f\u53ef\u4ee5\u53c2\u8003\u4ee5\u4e0b\u6211\u7684\u65b9\u6cd5\u3002\u6587\u7ae0\u6700\u540e\u6709\u6211\u7f16\u5199\u8fc7\u7a0b\u4e2d\u7684\u53c2\u8003\u6587\u7ae0\uff0c\u4e5f\u53ef\u4ee5\u6839\u636e\u53c2\u8003\u6587\u7ae0\u81ea\u5df1\u521b\u65b0\u3002<\/p>\n<h2 class=\"wp-block-heading\">\u73a9\u6cd51\uff1a\u53c2\u8003oracle\u5b98\u65b9\u6587\u6863\u5236\u4f5c<\/h2>\n<p>1.\u4e0b\u8f7d\u4ee3\u7801https:\/\/github.com\/oracle\/docker-images.git \u5230\u672c\u5730<\/p>\n<p>2.\u8fdb\u5165OracleInstantClient\/oraclelinux8\/21\/\u76ee\u5f55\uff0c\u8be5\u76ee\u5f55\u4e0b\u6709\u4e00\u4e2a\u539f\u59cb\u7684dockerfile\u6587\u4ef6\uff0c\u53ef\u4ee5\u4f7f\u7528\u8be5\u6587\u4ef6build\u4e00\u4e2a\u57fa\u7840\u955c\u50cf\uff0c\u4f8b\u5982<\/p>\n<pre class=\"wp-block-code\"><code>docker build --pull -t oracle\/instantclient:21 .\n<\/code><\/pre>\n<p>\u4f7f\u7528build\u51fa\u6765\u7684\u8fd9\u4e2aoracle\/instantclient:21\u955c\u50cf\u53ef\u4ee5\u4e8c\u6b21\u8fdb\u884cdockerfile\u7f16\u8f91\u52a0\u5165golang\u6216\u8005python\u3002<\/p>\n<p>\u4e5f\u53ef\u4ee5\u7528\u8fd9\u4e2aoracle\/instantclient:21\u6765\u6d4b\u8bd5\u4e00\u4e0boracle\u6570\u636e\u5e93\u662f\u5426\u80fd\u6b63\u5e38\u8fde\u63a5\u3002\u6d4b\u8bd5\u8fde\u63a5\u547d\u4ee4\u5982\u4e0b\uff1a<\/p>\n<pre class=\"wp-block-code\"><code>docker run -ti --rm oracle\/instantclient:21 sqlplus \u7528\u6237\u540d\/\u5bc6\u7801@\u6570\u636e\u5e93IP:\u6570\u636e\u5e93\u7aef\u53e3\/\u6570\u636e\u5e93\u540d\n<\/code><\/pre>\n<hr class=\"wp-block-separator has-alpha-channel-opacity\">\n<h2 class=\"wp-block-heading\">\u73a9\u6cd52\uff1a\u4ecedebian\u5f00\u59cb\u5236\u4f5c\u4e00\u4e2a\u955c\u50cf<\/h2>\n<p>\u9664\u4e86\u4e0a\u9762\u7684\u65b9\u6cd5\u5916\uff0c\u6211\u4eec\u8fd8\u53ef\u4ee5\u4ecedebian\u5f00\u59cb\u5236\u4f5c\u4e00\u4e2a\u5305\u542bpython\u7684\u955c\u50cf<\/p>\n<p>1.\u8fdb\u5165oracle\u5ba2\u6237\u7aef\u4e0b\u8f7d\u9875<a href=\"https:\/\/www.oracle.com\/database\/technologies\/instant-client\/linux-x86-64-downloads.html\">https:\/\/www.oracle.com\/database\/technologies\/instant-client\/linux-x86-64-downloads.html<\/a><\/p>\n<p>2.\u4e0b\u8f7dhttps:\/\/download.oracle.com\/otn_software\/linux\/instantclient\/218000\/instantclient-basic-linux.x64-21.8.0.0.0dbru.zip\u5230\u672c\u5730\uff0c\u5982\u4e0b\u56fe<\/p>\n<figure class=\"wp-block-image size-full\"><img fetchpriority=\"high\" decoding=\"async\" width=\"970\" height=\"301\" src=\"https:\/\/www.yinyubo.com\/wp-content\/uploads\/2022\/11\/image.png\" alt=\"\" class=\"wp-image-1229\"  sizes=\"(max-width: 970px) 100vw, 970px\"><\/figure>\n<p>3.\u7f16\u5199Dockerfile,\u4ee5debian+oracle+python\u4e3e\u4f8b<\/p>\n<pre class=\"wp-block-code\"><code>FROM debian:11-slim\n\nLABEL maintainer=\"zhenwei.li &lt;zhenwei.li@sfere-elec.com&gt;\"\nRUN set -eux \\\n    &amp;&amp; sed -i \"s@http:\/\/ftp.debian.org@https:\/\/repo.huaweicloud.com@g\" \/etc\/apt\/sources.list \\\n    &amp;&amp; sed -i \"s@http:\/\/security.debian.org@https:\/\/repo.huaweicloud.com@g\" \/etc\/apt\/sources.list \\\n    &amp;&amp; apt-get update \\\n    &amp;&amp; apt-get install -y -q libaio1 unzip python3 pip\n    &amp;&amp; pip install cx_Oracle\n\n# \u6e05\u7406\u5783\u573e\nRUN set -eux \\\n    &amp;&amp; apt-get clean \\\n    &amp;&amp; rm -rf \/var\/lib\/apt\/lists\/* \\\n    &amp;&amp; rm -rf \/tmp\/*\nENV TZ=Asia\/Shanghai \\\n    DEBIAN_FRONTEND=noninteractive\n\nRUN ln -fs \/usr\/share\/zoneinfo\/${TZ} \/etc\/localtime \\\n    &amp;&amp; echo ${TZ} &gt; \/etc\/timezone \\\n    &amp;&amp; dpkg-reconfigure --frontend noninteractive tzdata \\\n    &amp;&amp; rm -rf \/var\/lib\/apt\/lists\/*\n\nCOPY instantclient-basic-linux.x64-21.8.0.0.0dbru.zip \/opt\/oracle\/instantclient-basic-linux.x64-21.8.0.0.0dbru.zip\n\nWORKDIR \/opt\/oracle\/\n\nRUN unzip instantclient-basic-linux.x64-21.8.0.0.0dbru.zip\n\nRUN sh -c \"echo \/opt\/oracle\/instantclient_21_8 &gt; \/etc\/ld.so.conf.d\/oracle-instantclient.conf\"\n\nRUN ldconfig\n\nRUN useradd sfere<\/code><\/pre>\n<p>4. \u76ee\u5f55\u4e0b\u653eDockerfile\u548coracle\u5ba2\u6237\u7aefzip\u5305<\/p>\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"468\" height=\"168\" src=\"https:\/\/www.yinyubo.com\/wp-content\/uploads\/2022\/11\/image-1.png\" alt=\"\" class=\"wp-image-1230\"  sizes=\"auto, (max-width: 468px) 100vw, 468px\"><\/figure>\n<p>5.  \u5236\u4f5c\u955c\u50cf<\/p>\n<pre class=\"wp-block-code\"><code>docker build -t debian-oracle .<\/code><\/pre>\n<p>6.\u8fd0\u884c\u955c\u50cf\uff0c\u6d4b\u8bd5python\u8fde\u63a5oracle\u670d\u52a1\u7aef\u53ef\u884c,\u4f9d\u6b21\u8f93\u5165\u5982\u4e0b\u547d\u4ee4<\/p>\n<pre class=\"wp-block-code\"><code>docker run -ti --rm debian-oracle python\n<\/code><\/pre>\n<pre class=\"wp-block-code\"><code>import cx_Oracle as cx\ncon = cx.connect('\u7528\u6237\u540d', '\u5bc6\u7801', '\u6570\u636e\u5e93IP:\u6570\u636e\u5e93\u7aef\u53e3\/\u6570\u636e\u5e93\u540d')\n<\/code><\/pre>\n<h2 class=\"wp-block-heading\">\u53c2\u8003\u6587\u7ae0<\/h2>\n<p><a href=\"https:\/\/github.com\/oracle\/docker-images\/tree\/main\/OracleInstantClient\">https:\/\/github.com\/oracle\/docker-images\/tree\/main\/OracleInstantClient<\/a><\/p>\n<p><a href=\"https:\/\/csiandal.medium.com\/install-oracle-instant-client-on-ubuntu-4ffc8fdfda08\">https:\/\/csiandal.medium.com\/install-oracle-instant-client-on-ubuntu-4ffc8fdfda08<\/a><\/p>\n<\/p><\/div>\n<\/p><\/div>\n","protected":false},"excerpt":{"rendered":"<p>\u751f\u6210oracle\u5ba2\u6237\u7aefdocker\u955c\u50cf\u7684\u4e24\u79cd\u73a9\u6cd5 By \u674e\u9547\u4f1f 2022\u5e7411\u670816\u65e5 \u80cc\u666f \u6211\u4eec\u7684oracl [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-141","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/my.di.cloudns.asia\/index.php\/wp-json\/wp\/v2\/posts\/141","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/my.di.cloudns.asia\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/my.di.cloudns.asia\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/my.di.cloudns.asia\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/my.di.cloudns.asia\/index.php\/wp-json\/wp\/v2\/comments?post=141"}],"version-history":[{"count":1,"href":"https:\/\/my.di.cloudns.asia\/index.php\/wp-json\/wp\/v2\/posts\/141\/revisions"}],"predecessor-version":[{"id":142,"href":"https:\/\/my.di.cloudns.asia\/index.php\/wp-json\/wp\/v2\/posts\/141\/revisions\/142"}],"wp:attachment":[{"href":"https:\/\/my.di.cloudns.asia\/index.php\/wp-json\/wp\/v2\/media?parent=141"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/my.di.cloudns.asia\/index.php\/wp-json\/wp\/v2\/categories?post=141"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/my.di.cloudns.asia\/index.php\/wp-json\/wp\/v2\/tags?post=141"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}