{"id":313264,"date":"2021-01-18T18:41:04","date_gmt":"2021-01-18T10:41:04","guid":{"rendered":"http:\/\/4563.org\/?p=313264"},"modified":"2021-01-18T18:41:04","modified_gmt":"2021-01-18T10:41:04","slug":"%e8%af%b7%e6%95%99%e5%85%b3%e4%ba%8e-linux-%e7%b3%bb%e7%bb%9f-docker-%e7%9a%84%e4%b8%a4%e4%b8%aa%e9%97%ae%e9%a2%98","status":"publish","type":"post","link":"http:\/\/4563.org\/?p=313264","title":{"rendered":"\u8bf7\u6559\u5173\u4e8e Linux \u7cfb\u7edf docker \u7684\u4e24\u4e2a\u95ee\u9898"},"content":{"rendered":"<div>\n<div>\n<div>\n<h1>                  \u8bf7\u6559\u5173\u4e8e Linux \u7cfb\u7edf docker \u7684\u4e24\u4e2a\u95ee\u9898               <\/h1>\n<p> <\/p>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : zxCoder <\/span>  <span><i><\/i> 3<\/span> <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<div isfirst=\"1\"> <\/p>\n<h1>1<\/h1>\n<p> <\/p>\n<p>\u6211\u7528 docker \u542f\u52a8\u4e86\u4e00\u4e2a ubuntu \u5bb9\u5668\uff0c\u5728\u5bb9\u5668\u91cc\u521b\u5efa\u4e86\u4e00\u4e2a\u7528\u6237 zxc\uff0c\u7136\u540e<code>su zxc<\/code>\uff0c\u5207\u6362\u5230\u8fd9\u4e2a\u7528\u6237\uff0c\u7136\u540e\u6211\u5c31\u5207\u4e0d\u56de\u53bb\u4e86\u3002<\/p>\n<p><code>sudo<\/code>\u663e\u793a\u6ca1\u8fd9\u4e2a\u547d\u4ee4\uff0c\u67e5\u4e86\u4e00\u4e0b\u9700\u8981 apt \u5b89\u88c5\u8fd9\u4e2a<\/p>\n<pre><code>bash: sudo: command not found <\/code><\/pre>\n<p>\u4f46\u662f apt \u53c8\u663e\u793a\u6211\u6ca1\u6709\u6743\u9650\uff0c\u8981 root \u7528\u6237<\/p>\n<pre><code>E: Could not open lock file \/var\/lib\/dpkg\/lock-frontend - open (13: Permission denied) E: Unable to acquire the dpkg frontend lock (\/var\/lib\/dpkg\/lock-frontend), are you root? <\/code><\/pre>\n<p>\u6211\u73b0\u5728\u5e94\u8be5\u600e\u4e48\u505a<\/p>\n<h1>2<\/h1>\n<p> <\/p>\n<p>\u6211\u7528<code>adduser<\/code>\u547d\u4ee4\u6dfb\u52a0\u7528\u6237\u7684\u65f6\u5019\uff0c\u6709\u51e0\u4e2a\u8b66\u544a<\/p>\n<pre><code>adduser zxc perl: warning: Setting locale failed. perl: warning: Please check that your locale settings:         LANGUAGE = (unset),         LC_ALL = (unset),         LANG = \"en_US.UTF-8\"     are supported and installed on your system. perl: warning: Falling back to the standard locale (\"C\"). <\/code><\/pre>\n<p>\u7136\u540e\u5f53\u6211\u6309\u7167\u6587\u6863\u4f7f\u7528 PostgreSQL \u7684 initdb \u547d\u4ee4\u65f6\uff0c\u5c31\u62a5\u9519\u4e86<\/p>\n<pre><code>initdb: error: invalid locale settings; check LANG and LC_* environment variables <\/code><\/pre>\n<p>\u7f51\u4e0a\u67e5\u4e86\u5f88\u591a\u90fd\u6ca1\u7528\uff0c\u6bd4\u5982<\/p>\n<pre><code>~$ export LC_ALL=\"en_US.UTF-8\" bash: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8) <\/code><\/pre>\n<pre><code>~$ locale locale: Cannot set LC_CTYPE to default locale: No such file or directory locale: Cannot set LC_MESSAGES to default locale: No such file or directory locale: Cannot set LC_ALL to default locale: No such file or directory LANG=en_US.UTF-8 LANGUAGE= LC_CTYPE=\"en_US.UTF-8\" LC_NUMERIC=\"en_US.UTF-8\" LC_TIME=\"en_US.UTF-8\" LC_COLLATE=\"en_US.UTF-8\" LC_MONETARY=\"en_US.UTF-8\" LC_MESSAGES=\"en_US.UTF-8\" LC_PAPER=\"en_US.UTF-8\" LC_NAME=\"en_US.UTF-8\" LC_ADDRESS=\"en_US.UTF-8\" LC_TELEPHONE=\"en_US.UTF-8\" LC_MEASUREMENT=\"en_US.UTF-8\" LC_IDENTIFICATION=\"en_US.UTF-8\" LC_ALL=en_US.UTF-8 <\/code><\/pre>\n<p>\u8fd9\u79cd\u60c5\u51b5\u5e94\u8be5\u600e\u4e48\u89e3\u51b3\uff1f<\/p>\n<\/p><\/div>\n<div> <b>\u5927\u4f6c\u6709\u8a71\u8aaa<\/b> (<span>9<\/span>)        <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<ul>\n<li data-pid=\"5161557\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : boris93 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             1 \u3001\u5bb9\u5668\u672c\u6765\u5c31\u6ca1\u6253\u7b97\u8ba9\u4f60\u8fdb\u53bb\u64cd\u4f5c\uff0c\u6240\u4ee5\u6ca1\u88c5 sudo \u662f\u5f88\u6b63\u5e38\u7684<br \/>\u5728 Dockerfile \u91cc\u9762\u521b\u5efa\u597d\u7528\u6237\uff0c\u7136\u540e\u7528 USER \u6307\u4ee4\u5207\u6362\u5230\u8fd9\u4e2a\u7528\u6237\u7ee7\u7eed\u8dd1\u5269\u4e0b\u7684 Dockerfile<\/p>\n<p>2 \u3001Dockerfile \u91cc\u9762\u5148\u88c5\u597d locale \u7684\u5305\uff0c\u7136\u540e RUN \u521d\u59cb\u5316\u547d\u4ee4<\/p>\n<p>\u53e6\uff1a\u4e0d\u8981\u5728\u4e00\u4e2a\u955c\u50cf\u91cc\u8dd1\u4e00\u5806\u4e1c\u897f\uff0c\u4e00\u4e2a\u955c\u50cf\u53ea\u505a\u4e00\u4ef6\u4e8b\uff0c\u7528 docker-compose \u6216\u8005 k8s \u7f16\u6392\u670d\u52a1                                                            <\/p><\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5161558\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : carity <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u4e0a\u8bf4\u7684\u5bf9<\/p>\n<p>1. \u8bd5\u8bd5 su \u547d\u4ee4\uff0csu \u4e0d\u5e26\u53c2\u6570\u9ed8\u8ba4\u662f\u5207\u6362\u5230 root<br \/>2. \u4f60\u662f\u4ee5 zxc \u8eab\u4efd\u4f7f\u7528\u7684 PostgreSQL \u7684 initdb\uff0c\u8fd8\u662f\u4ee5 root \u8eab\u4efd\uff1f                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5161559\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : inwar <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             1. exit                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5161560\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : miv <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u4e0d\u662f\u8fd9\u4e48\u73a9\u7684\u554a\uff0c\u5982\u679c\u4f60\u60f3\u7528 PostgreSQL\uff0c\u90a3\u4e48\u5c31\u8981\u53bb\u76f4\u63a5\u627e\u4e00\u4e2a PostgreSQL \u7684 docker \u73af\u5883\u3002<br \/>\u4e0d\u662f\u8fdb\u5165\u4e00\u4e2a docker \u955c\u50cf\u91cc\u9762\u518d\u53bb\u5b89\u88c5\u4e00\u4e2a PostgreSQL \u3002\u672c\u6765 docker \u65b9\u4fbf\u5c31\u662f\u63d0\u4f9b\u4e86\u5404\u79cd\u8f6f\u4ef6\u7684\u73af\u5883\uff0c\u4f60\u8fd9\u641e\u548c\u666e\u901a\u64cd\u4f5c\u7cfb\u7edf\u6709\u5565\u4e2a\u533a\u522b\u5462\u3002\u8f6c\u4e00\u4e0b\u601d\u8def\u5427\u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5161561\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : zxCoder <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @miv \u60f3\u5f53\u505a\u4e00\u4e2a\u865a\u62df\u673a\u6765\u7740\u3002\u3002\u3002\u4e0d\u7136\u672c\u5730\u73af\u5883\u4e0d\u5c0f\u5fc3\u5c31\u641e\u4e71\u4e86                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5161562\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : zxCoder <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @inwar \u8fd9\u4e2a\u6709\u6548 \u611f\u8c22                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5161563\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : liujj <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             docker \u4e0d\u662f\u865a\u62df\u673a\uff0c\u4e00\u4e2a\u5bb9\u5668\u53ea\u505a\u4e00\u4ef6\u4e8b\uff1b\u4e00\u4ef6\u4e8b\u7684\u610f\u601d\u662f\u4e00\u4e2a\u903b\u8f91\u610f\u4e49\u7684\u4e3b\u8fdb\u7a0b\uff0c\u8fdb\u7a0b\u81ea\u5df1\u884d\u751f\u51fa\u6765\u7684\u7ebf\u7a0b\u5b50\u8fdb\u7a0b\u662f ok \u7684                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5161564\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : volvo007 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             docker \u7684\u4e00\u4e2a\u5bb9\u5668\u5c31\u5f53\u4e00\u4e2a\u8f6f\u4ef6\u6765\u7528\u5c31\u53ef\u4ee5\u4e86<br \/>\u65e5\u5e38\u4f60\u7528\u8f6f\u4ef6\u7684\u65f6\u5019\uff0c\u4e5f\u4e0d\u4f1a\u6ca1\u4e8b\u5c31\u5f80\u8f6f\u4ef6\u91cc\u9762\u585e\u81ea\u5df1\u7684\u4e1c\u897f\u5427<br \/>\u9700\u8981\u6bd4\u5982 nginx \u3001node \u3001PostgreSQL \u8fd9\u79cd\u4e1c\u897f\u8fde\u7528\u7684\u65f6\u5019\uff0c\u7528 docker- compose \u4e32\u8d77\u6765<\/p>\n<p>\u4e4d\u4e00\u770b\uff0c\u6bcf\u4e00\u4e2a app \u90fd\u9700\u8981\u4e00\u4e2a\u72ec\u7acb\u7684\u5bb9\u5668\uff0c\u800c\u6bcf\u4e00\u4e2a\u5bb9\u5668\u672c\u8eab\u53c8\u8dd1\u5728\u4e00\u4e2a\u7cbe\u7b80\u7684 Linux \u4e0a\uff0c\u597d\u50cf\u4f1a\u7ed9\u5bbf\u4e3b\u673a\u589e\u52a0\u5f88\u591a\u8d1f\u62c5<br \/>\u4f46\u5176\u5b9e\u9996\u5148 docker \u5f88\u8f7b\u91cf\uff0c\u5373\u4f7f\u8fd0\u884c\u51e0\u5341\u4e2a\u5bb9\u5668\uff0c\u5bf9\u4e8e\u670d\u52a1\u5668\u800c\u8a00\u4ecd\u7136\u5f88\u8f7b\u677e\u3002\u4f53\u79ef\u4e0a\u53ef\u80fd\u4e5f\u5c31\u591a\u51e0\u767e\u5146\u786c\u76d8\u800c\u5df2<br \/>\u53e6\u4e00\u65b9\u9762\uff0cdocker \u7684\u4f18\u52bf\u5728\u4e8e\u201c\u4e0d\u9700\u8981\u989d\u5916\u914d\u7f6e\u73af\u5883\u201d\u3002\u53ea\u8981\u4f60\u80fd\u4e0b\u8f7d\u3001\u80fd\u8dd1\u8d77\u6765\uff0c\u90a3\u5c31\u5fc5\u7136\u4e0d\u7528\u5173\u5fc3\u73af\u5883\u914d\u7f6e\u3002\u5355\u673a\uff0c\u6216\u8005\u5206\u4eab\u4f7f\u7528\u90fd\u53ef\u4ee5\u8282\u7701\u65f6\u95f4\uff0c\u800c\u4e14\u6269\u5c55\u4e00\u4e0b\u4e5f\u80fd\u8fdb\u884c\u96c6\u7fa4\u90e8\u7f72<\/p>\n<p>\u6211\u662f docker \u521a\u5165\u95e8\uff0c\u4e5f\u7528\u7684 PostgreSQL\uff0c\u4e60\u60ef\u4e4b\u540e\u611f\u89c9\u975e\u5e38\u65b9\u4fbf                                                            <\/p><\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5161565\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : cslive <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u8fd9\u3002\u3002\u3002\uff0cdocker \u4e0d\u662f\u8fd9\u4e48\u73a9\u7684\u554a\uff0c\u76f4\u63a5\u62c9\u955c\u50cf\u542f\u52a8\uff0cdocker \u5b98\u7f51\u955c\u50cf\u90fd\u6709\u8be6\u7ec6\u8bf4\u660e\u7684                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li>\n","protected":false},"excerpt":{"rendered":"<p>\u8bf7\u6559\u5173\u4e8e Linux \u7cfb\u7edf doc&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[],"tags":[],"_links":{"self":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/313264"}],"collection":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=313264"}],"version-history":[{"count":0,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/313264\/revisions"}],"wp:attachment":[{"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=313264"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=313264"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=313264"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}